Android kill all other activities on starting a new one
android, android-activity, android-intent, flags, kill-process
Solution
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);
Problem
I have an android activity problem. Here is how my process works: - `Login Activity` starts - Login successful. `MainMenuActivity` starts and LoginActivity is finished by me. - User touched on settings and SettingsActivity starts. `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`. - User touched on log out and `SettingsActivity` is finished by me and Login activity starts. As user returns the login I need to kill `MainMenuActivity` but I cant.:/ - I tried `FLAG_ACTIVITY_SINGLE_TOP`, `CLEAR_TOP`, `SINGLE_TASK`, `NEW_TASK`, `NO_HISTORY` etc.. almost all of them didnt work - I put `launchMode="singleTask"`, `clearTaskOnLaunh="true"` etc. didtn work again. - I tried `addFlags()` and `setFlags()` both, didnt work - There are some many issues about this topic here, I read and applied all the suggested solutions and didnt work. Can 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.