android Auto-Rotate configuration on change listener
Asked Answered
E

1

7

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 ...

Electrocautery answered 22/4, 2013 at 14:51 Comment(8)
This is the question ... what should i sign up for ...Electrocautery
https://mcmap.net/q/491681/-how-to-implement-a-contentobserver-for-call-logs take a look at that, should be what you wantInsociable
Try this link google.co.in/search?q=android:configchangesFornof
configChanges will only notify you when the rotation changes (among other things), you want to know when the Auto Rotate setting changes no?Insociable
@Insociable , yes, you are right, it might be in another way ... i just thought it will be this way, Can you please expand how the first link should help ? i wasn't able to understand where the auto-rotate comes in..Electrocautery
@sankarV , sorry it doesn't help, already tried it.Electrocautery
this should be more what you're looking for https://mcmap.net/q/89616/-is-there-a-broadcast-action-for-volume-changes you will need to tweak it to work for you but it should be fine, just remember that setting is in Accessibility.Insociable
check my answer.. although it is downvoted by some one :( but my answer is what you wanted... it responds when the auto rotation button is clickeCarl
C
14

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
        }
};
Carl answered 22/4, 2013 at 15:21 Comment(3)
he does not want to know when the device has rotated, he want's to know when the auto-rotate setting in accessibility has changed.Insociable
@Insociable I have posted exactly what he wanted.. From next time please check before downvotingCarl
@Insociable .. please dont downvote someone if you are not sure about somethingCarl

© 2022 - 2024 — McMap. All rights reserved.