I want to listen to 'Auto-Rotate' configuration change, not the device/system orientation, but to the toggle changes (on/off)
I believe i will have to sign up to configChange in the AndroidManifest and create a listener wherever i want but i'm not sure what is the correct config.
I.E.
android:configChanges='??'
But maybe another way exists and not through the android:configChanges
...
you have to listen to Settings.System.ACCELEROMETER_ROTATION using a content observer.
To register the content observer
getContentResolver().registerContentObserver(Settings.System.getUriFor
(Settings.System.ACCELEROMETER_ROTATION),
true,rotationObserver );
And declare it here. The onChange method will be called when the rotation is changed.
private ContentObserver rotationObserver = new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
Do your task
}
};
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