how to close android app completely how to close android app completely android android

how to close android app completely


To Quit Application on Button click use this code :

Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_HOME);startActivity(intent);

Try it..

To kill the complete app and remove it from Runningapp list kill the app through its pid(its nasty)... use this lines before above code.

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


If you want to close application completely you should use finishAffinity(); instead of finish() .It will clear all stack of activities previously opened by an application.


For API 21 and up

finishAndRemoveTask()

You can call this to close the app completely. All activities will finish() and the app is removed from the task list.