How to kill my own Activity - the hard way

后端 未结 8 581
灰色年华
灰色年华 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:46

    Similar to the System.exit(0) on the Java side, you can also call a native method during onDestroy which calls exit(0) on the C/C++ side. This seems to force the lib to exit completely. It's working for me!

    0 讨论(0)
  • 2021-01-31 11:50

    Try using the killBackgroundProcesses method:

    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    activityManager.killBackgroundProcesses("name.of.your.package");
    

    You will need to add the KILL_BACKGROUND_PROCESSES permission to your AndroidManifest.xml file.

    0 讨论(0)
提交回复
热议问题