简体   繁体   中英

Android 2.2.1, Orientation Change, and onDestroy()

I have a really heinous bug that I'm trying to track down and I've got the following situation.

Here's my scenario, I launch an activity, I change screen orientation to landscape, I change it again back to portrait, then I click on the device back button. After I do that, onDestroy of my activity is never called. It's called when I change orientation, but not when the user hits the back key.

  1. it only happens on Android 2.2.1 while debugger is not connected.
  2. it involves changing the screen orientation.
  3. onDestroy is never called after a screen orientation.

I'm at my wits end here and i'm looking for ideas on what could prevent the system from calling onDestroy...

Android docs state

Note: do not count on this method being called as a place for saving data! For example, if an        
activity is editing data in a content provider, those edits should be committed in either onPause() or
onSaveInstanceState(Bundle), not here. 

If you also look at the Killable column in the activity life cycle, the application can be killed by the system at any point after onPause on pre-honeycomb systems for whatever reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM