I am trying to comply with Android rotation lock setting. I want my application to be displayed in any orientation on which the home screen is locked. I found the following buttons:
- Settings.System.ACCELEROMETER_ROTATION - determine if the screen orientation is locked.
- Display.getRotation () - determines whether the device rotates from it in a "natural" orientation, which can be portrait or landscape.
- Display.getWidth () / getHeight () - determines the current orientation of the device.
I thought it would be easy to do, but I cannot find the right combination of the above to make it work. The values ββpresented seem inconsistent, especially during application startup (onResume the right place to check these values?).
Note. I donβt want to just always fix the orientation of my activity on portrait or landscape orientation, I want to configure it for the orientation in which the user locked the screen. For tablets, it can be a landscape or a portrait. If the user sets the auto-rotation setting, I want my activity to work in sensor mode.
source
share