How to kill my own Activity - the hard way

后端 未结 8 677
灰色年华
灰色年华 2021-01-31 10:59

So I have my Activity, and on pressing a \"Quit\" button I call Activity.finish(). This effectively closes my application.

The problem: The Dalvik-process of my applicat

8条回答
  •  甜味超标
    2021-01-31 11:39

    By using the ActivityManager we can close the another applications also.

    private ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    am.restartPackage("com.jimmy.appToBeClosed");
    

    to use the above code should have the android.permission.RESTART_PACKAGE permissions in manifest file.

提交回复
热议问题