Saturday, November 17, 2018

How to completely kill an app without it showing up in Android Task Manager

Here's how to completely kill an Android app without leaving the app's listing in the Task Manager.

moveTaskToBack(true);
if (android.os.Build.VERSION.SDK_INT >= 21) {
    finishAndRemoveTask();
} else {
    finish();
}
android.os.Process.killProcess(android.os.Process.myPid());

Existing data suggests using finish(), but starting with Android 6.0, you must call finishAndRemoveTask() so that the app does not remain in the task manager list after termination.

No comments:

Post a Comment