Skip to content Skip to sidebar Skip to footer

Problems When Handling Orientation Changes

I need to handle orientation changes in my Android application. For this purpose I decided to use OrientationEventListener convenience class. But his callback method is given somew

Solution 1:

This is a documented bug in the emulator ONLY. A real device will not exhibit this double-lifecycle-events behavior. I had the same issue a while ago and it disappears on a real device.

I would suggest ignoring the problem if you can by only testing orientation changes in one direction until you get your hands on a physical phone. Otherwise you might be able to "skip" the second set of lifecycle calls by keeping a static boolean around indicating you've already gone through the first set.

See this issue report for more info.

Solution 2:

Have you tried using onConfigurationChanged?

@OverridepublicvoidonConfigurationChanged(Configuration newConfig) {
 if(newConfig.equals(Configuration.ORIENTATION_LANDSCAPE)…

Solution 3:

Add android:configChanges="orientation" in manifest file in activity tag like

<activity android:label="@string/app_name" android:configChanges="orientation" android:name=".com.androidpeople">

Post a Comment for "Problems When Handling Orientation Changes"