Home

Saturday, March 20, 2010

How to save the application variables and screen values while the phone is rotated?

 

Having the EditText boxes filled with the values, rotating the phone clears the data. this is just because the Activity is getting restarted on the configuration change. The orientation and hardware keyboard show/hide are the common reason which is a part of the configuration change. Due to this, the EditText and other Widgets in the Android Activity can get reset.

To avoid this, the following flag must be used in AndroidManifest.xml file.

 

android:configChanges="keyboard|keyboardHidden|orientation"

I hope this will help your code!..

1 comment:

  1. You can also put some code in your onPause and onResume to save what was in the EditText and restore it.

    ReplyDelete