My application has android:configChanges="keyboardHidden|orientation” set in the manifest file. When I rotate my device, it appears that onConfigurationChanged() gets called twice.
I put log statements in my onConfigurationChanged() and the in the draw() of my layout’s main view. Based on the output from these logs, it appears that onConfugrationChanged() is called twice and that my layout does not resize until after the second the call.
Is there a reason for this and is it safe to assume this behavior will happen on all devices?
@Override
public void draw (Canvas canvas)
{
Log.e("view", getWidth() + " " + getHeight());
@Override
public void onConfigurationChanged(Configuration newConfig)
{
Log.e("rotated", "rotated");
12-15 16:27:36.605: ERROR/view(32510): 1280 700
12-15 16:27:36.630: ERROR/view(32510): 1280 700
12-15 16:27:37.000: ERROR/view(32510): 1280 700
12-15 16:28:29.215: ERROR/rotated(32510): rotated
12-15 16:28:29.220: ERROR/view(32510): 1280 700
12-15 16:28:29.330: ERROR/rotated(32510): rotated
12-15 16:28:29.380: ERROR/view(32510): 800 1180
12-15 16:28:29.425: ERROR/view(32510): 800 1180
12-15 16:28:29.525: ERROR/view(32510): 800 1180
12-15 16:28:29.810: ERROR/view(32510): 800 1180
Try the following code in your onConfiguration() method to determine what is happening on the separate calls to the onConfiguration() method:
The values of the configuration flags are documented at:
http://developer.android.com/reference/android/content/res/Configuration.html