I have an android activity problem.
Here is how my process works:
Login Activity
startsMainMenuActivity
starts and LoginActivity is finished by me.MainMenuActivity
is NOT finished. because is it the main menu. when user presses the back on settings screen I need to go back MainMenuActivity
. so I cant kill MainMenu
.SettingsActivity
is finished by me and Login activity starts. As user returns the login I need to kill MainMenuActivity
but I cant.:/FLAG_ACTIVITY_SINGLE_TOP
, CLEAR_TOP
, SINGLE_TASK
, NEW_TASK
, NO_HISTORY
etc.. almost all of them didnt worklaunchMode="singleTask"
, clearTaskOnLaunh="true"
etc. didtn work again.addFlags()
and setFlags()
both, didnt workCan anyone help, please?
P.S android:minSdkVersion="8"
and android:targetSdkVersion="15"
for my app. I didnt use fragments in the app, I use old activity structure.
exit(); or finish(); it exit full application or all activity.
The Activity lifecycle is especially important because whenever an activity leaves the screen, the activity can be destroyed. When an activity is destroyed, when the user returns to the activity, the activity will be re-created and the lifecycle methods will be called again.
Use the combination of two flags like this:
Intent intent = new Intent(this, Login.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
This deletes all the other activities and starts this one.
Try this.
For api level <11
i.addFlag(Intent.FLAG_ACTIVITY_NO_HISTORY |
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With