I need to prevent the upside-down portrait orientation in my app, but still allow all three of the other orientations to be triggered by physically rotating the device.
I'm calling setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
(which I understand to be the default) in onCreate()
of my activities. The reason I am calling this is because some of my screens need to be specifically set to portrait and/or landscape, but most screens by default use the sensor.
This seems to result in my desired behaviour on some devices (Nexus 6, Samsung Galaxy S4), but the Nexus 7 displays portrait upside down mode when the device is held upside down. For unrelated reasons I can't allow this.
Is there a way to disable portrait upside-down on all devices but still allow the other 3 modes?
Unspecified let's the implementation decide what it wants to do. On the Neus 7, this is apparantly to allow everything, like SCREEN_ORIENTATION_FULL_SENSOR
.
You could circumvent this by specifying the slightly less "Do whatever you want" option, being SCREEN_ORIENTATION_SENSOR
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.