-6

I would like to know, is there an OS/Built-in Timer to call onDestroy() method or Kill my app's process?

If yes, how much?

Because i tried to Track my closed app from Settings->Applications->Manage apps, and the STOP Button was Enabled, then after Few seconds its gone/disabled.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
  • 1
    onDestroy does not have a timer, it can be called at anytime when your app is in the background by the OS when the OS needs to reclaim resources – tyczj Sep 16 '14 at 14:34
  • Please read this one. http://stackoverflow.com/questions/7536988/android-app-out-of-memory-issues-tried-everything-and-still-at-a-loss/7576275#7576275 – hemu Sep 16 '14 at 15:04
  • 1
    To answer the question: Your app can be killed at any moment. You have to develop it with that in mind. – Xaver Kapeller Sep 16 '14 at 15:14

1 Answers1

2

The system will decide when to kill your app's process, usually when it wants to reclaim memory so that other apps can run. There is no guaranteed timing of this or of the onDestroy callback.

If you need to destroy your Activity, call finish() explicitly; if you need to destroy your Service, call stopSelf() or use stopService() from an Activity (or from anything that is/has a Context). If either of those need to be based on a timer, you can use AlarmManager to set up a PendingIntent and perform the above actions when it fires.

Karakuri
  • 38,365
  • 12
  • 84
  • 104
  • 1
    Well, i think i got it... its about "NO HISTORY" tag in Manifest file. When i set it to TRUE, OS will kill my App's process in background. (while its hide) – Yousha Aleayoub Sep 16 '14 at 15:48