Issue
I have three activities:
- LoginActivity
- OptionsActivity
- OkActivity
App lifecycle is 1 > 2 > 3.
Say user is in 3 and press home button, then the app is closed. Then, the user reopen the app and 1 is opened. However, if back button is pressed, 3 is shown. I want to close the app when home button is pressed. Or clear activities stack when 1 is opened.
I have tried to put android:clearTaskOnLaunch="true" in LoginActivity but it doesn't work (same behavior).
Thanks.
Solution
You can override the method OnBackPressed in the activity 1 (LoginActivity) like this:
@Override
public void onBackPressed() {
moveTaskToBack(true);
this.finish();
}
This should exit the app correctly when button "Back" is pressed on the LoginActivity.
Answered By - miselking
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.