Android-Close Other Apps

前端 未结 5 715
甜味超标
甜味超标 2020-12-03 19:38

I have some code that will launch a different application using intents but what can I do to close or kill the other app?

Here is the launch code (works great):

5条回答
  •  醉酒成梦
    2020-12-03 20:09

    Basic answer, you can't. As of Froyo, the only facility available is ActivityManager.killBackgroundProcess(), which:

    (a) Only allows you to kill processes that are, as it said, in the background and not visible to the user. That is, it does not allow you to disrupt the normal execution of the other app.

    (b) Is not needed anyway, because Android will kill the background processes for you if it needs their memory.

    You simply do not need to do what you at this point seem to think you do. "Because my users have asked for it" is not a reason to be going around killing other people's processes.

提交回复
热议问题