Has Android orientation stopped working on latest daily build?

I updated to 2830 yesterday, and also updated my Android SDK to API 23 now that Corona supports the new features.  

However, changing the device orientation doesn’t cause anything to happen in game any more. Our app has supported both landscape and portrait orientations for over a year now, and I haven’t made any changes to that recently. I tested an apk that I made 2 days ago, and the orientation still works in that.

Has anyone else experienced the same thing?

Hi Alan QuizTix,

On your device, make sure that the “auto-rotate screen” setting is enabled. Depending on what device your on, this may be located in different places in the Settings app and possibly under a different name.

On vanilla versions of Android 5, this would be in Settings -> Accessibility.

On Samsung and devices, swiping down from the status bar should reveal a Screen Rotation setting.

On a Kindle device with Fire OS 5 and above, this would be under Settings -> Display and instead be called, “When Device is Rotated”

Prior versions of Corona SDK would ignore this setting, letting Corona apps rotate to any supported rotation. As of daily build 2747, Corona-made apps will now respect this setting.

Hi Ajay, auto-rotate was definitely on. In fact I never turn it off, but it was the first thing I thought of when the app stopped rotating so I double checked and it was turned on.  

Also, we tested on 3 different devices and the app failed to rotate on all 3 (Samsung Galaxy S4, Nexus 7 and a Xiaomi phone).

We’re actually using Enterprise rather than the SDK, is there perhaps a new setting I need to add to my AndroidManifest.xml file? Currently it looks like this:

android:screenOrientation="user" android:configChanges="keyboardHidden|screenSize|orientation" android:label="@string/app\_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"\> \<meta-data android:name="supportsOrientationPortrait" android:value="true" /\> \<meta-data android:name="supportsOrientationPortraitUpsideDown" android:value="true" /\> \<meta-data android:name="supportsOrientationLandscapeRight" android:value="true" /\> \<meta-data android:name="supportsOrientationLandscapeLeft" android:value="true" /\>

Edit: I should also mention that in the device’s logcat, I can see that the device is processing some rotation stuff, but there’s no Corona code to say it’s rotating (I have an orientation listener which should be printing out):

02-26 09:24:52.345 818-818/? D/CAE: onGetSensorHubData(SensorHubParserProvider.java:69) - onGetSensorHubData Event [event buffer len :4] 02-26 09:24:52.345 818-818/? I/CAE: parse(SensorHubParserProvider.java:142) - buffer size = 4 02-26 09:24:52.345 818-818/? I/CAE: parse(SensorHubParserProvider.java:153) - 1, 1, 7, 1, 02-26 09:24:52.345 818-818/? D/CAE: display(ContextProvider.java:357) - ================= AUTO\_ROTATION ================= 02-26 09:24:52.345 818-818/? I/CAE: display(ContextProvider.java:373) - Angle=[1] 02-26 09:24:52.345 818-818/? D/SContextService: updateSContext() : event = Auto Rotation 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.onSContextChanged, Rotation: 1 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: false 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, Rotation: 1 02-26 09:24:52.345 818-818/? V/WindowManager: rotationForOrientationLw(orient=-1, last=0); user=0 sensorRotation=1 mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false gripRotationLock=false 02-26 09:24:52.355 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: false 02-26 09:24:52.355 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, Rotation: 1

Solved it, as always just after posting…

Changing my manifest so that

android:screenOrientation="user"

became

android:screenOrientation="sensor"

seems to have done the trick.

Yep. that’ll do it. Specifically, there’s a subset of screenOrientation settings that Corona supports. In this case, if you provide “user” in the AndroidManifest.xml, Corona will automatically change it to “portrait”. This would be why orientation changes weren’t occurring when you updated.

CoronaActivity.setRequestedOrientation() details which screenOrientation settings Corona supports and what will happen if you try to use an unsupported orientation. Here’s the relevant piece:

Overridden to deny support for orientation settings that Corona does not support, such as settings that prevent Corona from predicting the orientation of the display. For example, ActivityInfo.SCREEN_ORIENTATION_USERand ActivityInfo.SCREEN_ORIENTATION_BEHIND might or might not support fixed orientations.

This activity will use ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED if given the following orientations:

ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED is used so that the OS will respect auto-rotate settings.

This activity will use ActivityInfo.SCREEN_ORIENTATION_PORTRAIT if given the following orientations:

This activity will use ActivityInfo.SCREEN_ORIENTATION_SENSOR_[PORTRAIT/LANDSCAPE] if given ActivityInfo.SCREEN_ORIENTATION_USER_[PORTRAIT/LANDSCAPE] as of daily build 2015.2747.

Hi Alan QuizTix,

On your device, make sure that the “auto-rotate screen” setting is enabled. Depending on what device your on, this may be located in different places in the Settings app and possibly under a different name.

On vanilla versions of Android 5, this would be in Settings -> Accessibility.

On Samsung and devices, swiping down from the status bar should reveal a Screen Rotation setting.

On a Kindle device with Fire OS 5 and above, this would be under Settings -> Display and instead be called, “When Device is Rotated”

Prior versions of Corona SDK would ignore this setting, letting Corona apps rotate to any supported rotation. As of daily build 2747, Corona-made apps will now respect this setting.

Hi Ajay, auto-rotate was definitely on. In fact I never turn it off, but it was the first thing I thought of when the app stopped rotating so I double checked and it was turned on.  

Also, we tested on 3 different devices and the app failed to rotate on all 3 (Samsung Galaxy S4, Nexus 7 and a Xiaomi phone).

We’re actually using Enterprise rather than the SDK, is there perhaps a new setting I need to add to my AndroidManifest.xml file? Currently it looks like this:

android:screenOrientation="user" android:configChanges="keyboardHidden|screenSize|orientation" android:label="@string/app\_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"\> \<meta-data android:name="supportsOrientationPortrait" android:value="true" /\> \<meta-data android:name="supportsOrientationPortraitUpsideDown" android:value="true" /\> \<meta-data android:name="supportsOrientationLandscapeRight" android:value="true" /\> \<meta-data android:name="supportsOrientationLandscapeLeft" android:value="true" /\>

Edit: I should also mention that in the device’s logcat, I can see that the device is processing some rotation stuff, but there’s no Corona code to say it’s rotating (I have an orientation listener which should be printing out):

02-26 09:24:52.345 818-818/? D/CAE: onGetSensorHubData(SensorHubParserProvider.java:69) - onGetSensorHubData Event [event buffer len :4] 02-26 09:24:52.345 818-818/? I/CAE: parse(SensorHubParserProvider.java:142) - buffer size = 4 02-26 09:24:52.345 818-818/? I/CAE: parse(SensorHubParserProvider.java:153) - 1, 1, 7, 1, 02-26 09:24:52.345 818-818/? D/CAE: display(ContextProvider.java:357) - ================= AUTO\_ROTATION ================= 02-26 09:24:52.345 818-818/? I/CAE: display(ContextProvider.java:373) - Angle=[1] 02-26 09:24:52.345 818-818/? D/SContextService: updateSContext() : event = Auto Rotation 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.onSContextChanged, Rotation: 1 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: false 02-26 09:24:52.345 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, Rotation: 1 02-26 09:24:52.345 818-818/? V/WindowManager: rotationForOrientationLw(orient=-1, last=0); user=0 sensorRotation=1 mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false gripRotationLock=false 02-26 09:24:52.355 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, mbResultFaceDectection: false 02-26 09:24:52.355 818-818/? V/WindowOrientationListener: mSContextAutoRotationListener.getProposedRotation, Rotation: 1

Solved it, as always just after posting…

Changing my manifest so that

android:screenOrientation="user"

became

android:screenOrientation="sensor"

seems to have done the trick.

Yep. that’ll do it. Specifically, there’s a subset of screenOrientation settings that Corona supports. In this case, if you provide “user” in the AndroidManifest.xml, Corona will automatically change it to “portrait”. This would be why orientation changes weren’t occurring when you updated.

CoronaActivity.setRequestedOrientation() details which screenOrientation settings Corona supports and what will happen if you try to use an unsupported orientation. Here’s the relevant piece:

Overridden to deny support for orientation settings that Corona does not support, such as settings that prevent Corona from predicting the orientation of the display. For example, ActivityInfo.SCREEN_ORIENTATION_USERand ActivityInfo.SCREEN_ORIENTATION_BEHIND might or might not support fixed orientations.

This activity will use ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED if given the following orientations:

ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED is used so that the OS will respect auto-rotate settings.

This activity will use ActivityInfo.SCREEN_ORIENTATION_PORTRAIT if given the following orientations:

This activity will use ActivityInfo.SCREEN_ORIENTATION_SENSOR_[PORTRAIT/LANDSCAPE] if given ActivityInfo.SCREEN_ORIENTATION_USER_[PORTRAIT/LANDSCAPE] as of daily build 2015.2747.