开发者

How to force close my Android application?

开发者 https://www.devze.com 2023-03-11 10:38 出处:网络
Well apparently my android application doesnt close when I finish the activity so it there a way to force close it including any activity in my app t开发者_如何学编程hat could be opened?The fact that

Well apparently my android application doesnt close when I finish the activity so it there a way to force close it including any activity in my app t开发者_如何学编程hat could be opened?


The fact that the process is still alive does not mean that the Activities did not finish. The process might be kept for a while until the OS decides to kill it.

If you have activities that do not finish properly, make sure that you did not leave a thread running.

There is no method in the API to close an Application. It is up to the OS to terminate it when it is convenient. The last resource is to kill the process, but you should never need to use that in your apps.


Make sure that threads that you have started terminate, and then invoke finish

Btw. How have you verified that you activity isn't closing?


Call finish() at the point when you want it to close. For example in onPause() if you want it to finish when the activity is no longer the topmost one.

I personally suggest you simply make sure your app does not do anything when it is not active and let the system worry about 'finishing' it.

0

精彩评论

暂无评论...
验证码 换一张
取 消