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).
source
share