Kleptine
Kleptine

Reputation: 5087

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

Upvotes: 2

Views: 2789

Answers (2)

Felix
Felix

Reputation: 89566

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.

Upvotes: 6

Skizit
Skizit

Reputation: 44842

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.

Upvotes: 1

Related Questions