android hibernation kill the app - onDestroy

1k Views Asked by At

I'm developing with API level 8 on android 2.2

I read this about the life cycle of an android app : http://developer.android.com/reference/android/app/Activity.html but there is no comments about the hibernation state and how to handle it correctly...

when I switch off the device (and when my app is still running) the os calls the onDestroy method... and when I switch on the device my app start from the beginning, the os calls the onCreate method...

it could be better that the os calls only the onPause / onResume on hibernation, no ?

I look about Angry Birds on android and it is still living when the device switch on, they don't reload textures or anything else like one instant...

so how to do the same ? :)

2

There are 2 best solutions below

0
On BEST ANSWER

add in the manifest xml file :

  • android:launchMode="singleTask"
  • android:configChanges="keyboardHidden|orientation"

thx to Chris & to all

4
On

you would need a partial wake lock, so that your application would continue to run even when the screen is switched off. In a partial wake lock, the CPU is not put to sleep and only the screen is dimmed. I think this is what the Angry Birds game does. http://developer.android.com/reference/android/os/PowerManager.WakeLock.html