Monday, March 01, 2010

Android: How to prevent activity from restarting when configuration changes?

[Problem]
Slide the hardware keyboard of G1 out, and the current activity will be re-created

[Cause]
Configuration changes (slide keyboard out) will trigger system to destroy your current activity, and then re-create a new instance of the activity

[Solution]
Specify that the activity would like to handle certain configuration changes by itself in AndroidManifest.xml
For example: configchanges="keyboardHidden|keyboard"

click: Android reference for more information

No comments:

Post a Comment