Skip to content Skip to sidebar Skip to footer

Android Exit Application

it's not recommended to exit application directly, so the point is to finish all activities so everything goes to the background and user returns to the home screen. My problem is

Solution 1:

When setting this 2 flags MainActivity will not reach onCreate() if it is still in the stack. This would call onNewIntent().

Check this 2 links for more information:

http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP

http://developer.android.com/reference/android/app/Activity.html#onNewIntent%28android.content.Intent%29

Solution 2:

System.Exit(0);

//You can use that to exit the entire application, not just one activity

Solution 3:

Set Launch Mode of MainActivity as "SingleTop" in AndroidManifest.xml file as follows:

android:launchMode="singleTop"

Solution 4:

I don't know if it is the best solution, but work to me:

On Event Listener:

int pid = android.os.Process.myPid(); 
android.os.Process.killProcess(pid); 

Solution 5:

call moveTaskToBack(true) on your Activity

Post a Comment for "Android Exit Application"