开发者

Android Keep Activity from Dieing

The main Activity I use in my Android application uses a fair amount of memory, meaning that on a less powerful phone, it is susceptible to being killed off when not at the front. Normally this is fine, but it also happens when I am stil开发者_运维技巧l inside my application, but have a different activity at the top of the stack (such as a preference activity).

Obviously it's a problem if my application is killed while the user is still running it. Is there any way to disable the OS's ability to kill off the application for low memory problems?

Thanks.


No, there's no way. Your options are:

  1. Read about Activity lifecycle and Activity and Task Design and implement these correctly and efficiently.
  2. Use a Service.


It can't be done sadly. You see the linux Kernel will kill your application if it threatens the OS's ability to function. Sadly your application cannot prevent this. If it could I'm sure you can see the security implications of such things.

Sorry.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜