android - How to handle activities stack? -


i have 4 activities. 2 of them login/registration. after successful login, user moves activity rooms user can select room chat in. can press , select room chat in two/multiple rooms. dont want finish chat activity. when user press back(twice) @ room activity whole app should finish.

but rather finishing launches chat activity throwing error because has lost data. how can accomplish that. chat activity launched customadapter , launches room activity on backpress using flag reorder front.

update:

i not want finish chat activity on press. know how finish() works. want clear stack , exit on backpress of room activity.

suggestion: don't teach me how finish activity calling finish or how exit on double backtap. if don't have sufficent knowledge flags there no need load stackoverflow junk.

try :

boolean doublebacktoexitpressedonce = false;  @override public void onbackpressed() {     if (doublebacktoexitpressedonce) {         super.onbackpressed();         return;     }  this.doublebacktoexitpressedonce = true; toast.maketext(this, "please click again exit", toast.length_short).show();  new handler().postdelayed(new runnable() {      @override     public void run() {         doublebacktoexitpressedonce=false;                            } }, 2000); 

}


Comments