Thursday, March 31, 2011

[android-developers] destruction and creation of android activity happens TWICE upon changing the screen orientation

Scenario 1 - NORMAL
###################### application activity started ###########################
03-31 17:52:18.413: INFO/System.out(589): onCreate()
03-31 17:52:18.974: INFO/System.out(589): onWindowFocusChanged() -> hasFocus:true
03-31 17:52:18.974: INFO/System.out(589): mySoundPlaybackMethods()
########## back button pressed to remove activity from the task ###############
03-31 17:54:54.113: INFO/System.out(589): onWindowFocusChanged() -> hasFocus:false
03-31 17:54:54.514: INFO/System.out(589): onDestroy()
###################### application activity finished ##########################


Scenario 2 - ABNORMAL
######################## application activity started ##########################
03-31 17:52:18.413: INFO/System.out(589): onCreate()
03-31 17:52:18.974: INFO/System.out(589): onWindowFocusChanged() -> hasFocus:true
03-31 17:52:18.974: INFO/System.out(589): mySoundPlaybackMethods()
########################### screen orientation changed #########################
03-31 17:52:38.393: INFO/System.out(589): onSaveInstanceState() -> state saved
03-31 17:52:38.403: INFO/System.out(589): onDestroy()
03-31 17:52:38.514: INFO/System.out(589): onCreate()
03-31 17:52:39.464: INFO/System.out(589): onRestoreInstanceState() -> state restored from old bundle
---------------------------------------------------------------------------------------------------------------
?????? in the following output, why should the same steps of destruction/creation of activity happen ONCE AGAIN ??????
---------------------------------------------------------------------------------------------------------------
03-31 17:52:39.504: INFO/System.out(589): onSaveInstanceState() -> state saved
03-31 17:52:39.504: INFO/System.out(589): onDestroy()
03-31 17:52:39.524: INFO/System.out(589): onCreate()
03-31 17:52:40.024: INFO/System.out(589): onRestoreInstanceState -> state restored from old bundle
03-31 17:52:40.104: INFO/System.out(589): onWindowFocusChanged() -> hasFocus:true
---------------------------------------------------------------------------------------------------------------
???? the last call to onWindowFocusChanged() occured with hasFocus=TRUE; 
???? this call to to onWindowFocusChanged() also occured with hasFocus=TRUE;
???? when did the windowFocus even change to FALSE?
---------------------------------------------------------------------------------------------------------------
03-31 17:52:40.104: INFO/System.out(589): mySoundPlaybackMethods()
############## back button pressed to remove activity from the task ################
03-31 17:54:54.113: INFO/System.out(589): onWindowFocusChanged() -> hasFocus:false
03-31 17:54:54.514: INFO/System.out(589): onDestroy()
######################### application activity finished ############################

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment