I have an application with many activities, sharing the same Menu, which is created in a code module. This Menu has an option "Exit". How do I finish all running activities without using ExitApplication? Do I have to create a variable in the code module (ExitNow as boolean) and check it in every Activity_Resume of every activity?
Asked
Active
Viewed 5,365 times
4 Answers
1
put activity.finish as the code for your exit button

Niall Daly
- 26
- 1
-
You could add a flag as a single – Niall Daly Aug 26 '12 at 18:22
-
on finish you could have flag=flag+1 and check the value of flag on resumsion also changing flag back to 0 at that time. – Niall Daly Aug 26 '12 at 18:23
1
try this one.
Intent intent = new Intent(getApplicationContext(), Home.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

Umesh Suryawanshi
- 934
- 1
- 7
- 21
0
I tried a lot of examples but this really worked for me
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Nabeel K
- 5,938
- 11
- 38
- 68