Improvements to orientation locking on Android


CX Code Contributor
3rd Party Module Dev
3rd Party Tool Dev
Nov 19, 2019
When locking the orientation to landscape or portrait we should let the player also use landscape flipped and portrait flipped. Sometimes it's nice depending on where the headphone jack is or side buttons.

We could change the suggested orientations from "portrait" and "landscape" to "userPortrait" and "userLandscape"

But since this requires API level 18 we should add backwards compatibility in Java. (Note: We still want to lock the orientation in the manifest too, because that gives it a better launch animation.)

Also I noticed there seems to be what may be a copy/paste error where onStart, onRestart, and onStop all call super.onResume(), so I changed that.

Yes, they require a newer version be targeted every year when releasing on Google Play. Cerberus-X currently targets 28 and requires 16 by default, but I didn't do any changes on that.
They update so damn quickly that you can't even get the time to read a book about one of the versions before another one is released!
Yup, if I had a say, I would drop that and the ios target :) To much effort.
On Android you can simply use sensorPortrait or sensorLandscape. The view is locked into portrait/landscape but if you rotate the phone the view will also rotate.

It is what I have used in all my games :)
According to the docs for Android "The sensor is used even if the user has locked sensor-based rotation."

I'm a perfectionist, so that is why I like using "user" instead.
Top Bottom