Tuesday, 22 January 2019

onConfigurationChanged not called for 180 and 270 degrees

I have faced a strange issue (or maybe unexpected behavior) on my Android device.

The problem is that I am listening for configuration changes in my DialogFragment like this:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    // Do something secret here :)
}

I added android:configChanges to the Activity which is responsible for showing the dialog fragment

<activity
    android:name=".SecretActivity" 
    android:configChanges="orientation|screenSize"
    android:windowSoftInputMode="adjustResize" />

and indeed I am getting callbacks from the system when I am rotating device, but not in all cases. As you can see in the picture onConfigurationChanged( ) called only when I am rotating 90 degrees, and also 360, in other cases it is not called.

Is this an expected behavior? If yes, how I can detect all rotations (90, 180, 270, 360)?

enter image description here



from onConfigurationChanged not called for 180 and 270 degrees

No comments:

Post a Comment