14.02.2011 23:13, Kevin Duffey пишет:
Incidentally, I don't know if there are other reasons for restarting activities on orientation changes, but I know one reason it's done is to allow potential layout changes to occur. You can provide layouts for both landscape and portrait. I don't know why some sort of event handler couldn't be called without restarting the entire activity...

There is just such handler - onConfigurationChanged:

http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged(android.content.res.Configuration)

... but you have to tell Android that your code is able to handle it:

http://developer.android.com/guide/topics/manifest/activity-element.html#config

Note that there are more potential config change cases than just the orientation change - in particular, the user may change the phone's locale setting - other cases are listed on the page above.

The automatic destroy / recreate cycle is there as a catch-all, with the onConfigurationChanged providing a possibility for an optimization.

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

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

Reply via email to