Killing android application on pause

大憨熊 提交于 2019-11-28 10:05:47

Implement onPause() in your activity and call finish() on your activity. Bear in mind, though, that this will occur on every pause, including dialogs, incoming calls, users activating a Notification. You might want to consider doing finish() in onStop(), which would at least solve the dialog problem.

Also, bear in mind that users will may get confused when using your app, thinking it has crashed since it is gone when they try to get back to it.

you can easily do that by setting true the "noHistory" attribute in to your activity element, in the manifest

http://developer.android.com/guide/topics/manifest/activity-element.html#nohist

You know how you have an OnCreate() method in your activity which performs actions when you start. You need to add something like:

@Override

protected void onPause(){
finish();

        super.onPause();

}

in your activity to add actions before it starts

in this case the

finish(); 

command is what you want to execute before your activity pauses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!