views:

115

answers:

2

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 still 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.

+1  A: 

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.

Ulkmun
Even though I'm still inside my own application?
GuyNoir
Yes, from my understanding if your application is sucking up too much resources the linux Kernel will destroy it. Android tries it's best to keep whatever the user can see alive. If it takes more resources it will kill background applications and then if memory is at a critical level it will kill whatever is in the foreground in order to keep Android alive.You can't ask more than what resources are available. A way around your problem would be to do most of the computation that your doing server side.
Ulkmun
+3  A: 

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.
Felix