开发者

Android: how to avoid from my process being killed

This may be discussed before, but i didn't find answer. I've problem with my application beeing killed开发者_StackOverflow中文版 when some other apps needs memory. I looked at Activity Lifecycle and tested my app. All i want to know is: when in one of my processes are called onPause() or onStop() and other apps needs memory, how to avoid from my process being killed.


You can't avoid this. When system needs memory or does cleanup, it can kill application.

However you may somehow control importance of your application, so that it may live longer. Read here about importance of various application parts related to process killing: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html#Lifecycle

To have long-running application, implement Service. However, also Service may be killed, but system schedules to restart killed or crashed services after some time.


This isn't possible, every application is treated equally in android and one of the things you have to consider is that your app might be killed. You can keep services running, that might do what you want if it's something in the background.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜