Using code below, I can enable or disable auto-rotation for whole device
Settings.System.putInt(
getActivity().getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION,
orientationEnabled //0 means off, 1 means on
);
How can I do same but restricted to my app? I dont want to change global settings forcing user to restore them, after he used my app.
EDIT:
I want to change that setting on runtime, not to lock it permanently.
E.g at some point to enable auto rotation, so use can change orientation, if he want, but not to force him (thus this solution does not fit).