Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to avoid from my process being killed

Tags:

android

This may be discussed before, but i didn't find answer. I've problem with my application beeing killed 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.

like image 400
Uroš Podkrižnik Avatar asked Sep 16 '11 07:09

Uroš Podkrižnik


1 Answers

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.

like image 70
Pointer Null Avatar answered Oct 13 '22 18:10

Pointer Null