Check if the device is locked in portrait mode

Is there a way to get information if the device settings allow you to lock the screen orientation?

+4
source share
1 answer

You can check the value of Settings.System.ACCELEROMETER_ROTATION as follows:

final int rotationState = android.provider.Settings.System.getInt(
    getContentResolver(), 
    Settings.System.ACCELEROMETER_ROTATION, 0
);

When auto-rotation is turned on, this value is 1 (and 0 otherwise).

+4
source

All Articles