I think each android device has an abitily to on/off auto-rotating function.
Usually you can find it in settings->display->auto-rotate on/off
. How can I read this setting state from my application? How can I access to this setting value? If you can share a code snipped i'd be very appreciate it.
Turn On Screen Rotation From Android SettingsLaunch the Settings app on your Android phone. Tap Display in the list of items. Turn on the option that says Auto-rotate screen.
Swipe down from the top of the screen to open the Quick settings panel. Look for the screen orientation icon. Depending on your settings, you may need to look for the Portrait, Landscape, or Auto Rotate icon.
If the screen rotation is already on try turning it off and then on again. To check this setting, you can swipe down from the top of the display. If it's not there, try going to Settings > Display > Screen rotation.
Hope this code snippet helps you out:-
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
if (android.provider.Settings.System.getInt(getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, 0) == 1){
Toast.makeText(getApplicationContext(), "Rotation ON", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(getApplicationContext(), "Rotation OFF", Toast.LENGTH_SHORT).show();
}
super.onCreate(savedInstanceState);
}
Use the following code:
if (android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
Toast.makeText(Rotation.this, "Rotation ON", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Rotation.this, "Rotation OFF", Toast.LENGTH_SHORT).show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With