문제

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

add in the manifest xml file :

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

thx to Chris & to all

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top