I want to change the screen orientation settings of android devices from my app from any mode to "Auto Rotate". This change is not only for my app but for whole device. I have "Root Access" also but if this thing is possible without root access then it will be much better. There are already apps in playstore like "Rotation Control" which does this stuff but I have no idea how it works and I am only getting docs and tutorials to change screen orientation at application level but I want at device level. So at least please guide me a bit or any idea would be helpful.
Asked
Active
Viewed 362 times
1
-
I don't see any sense in putting this question on hold as user has already got the answer and a similar thread already exist on stackoverflow and without any hold. Please use your mod rights wisely. – suv Oct 16 '18 at 11:17
2 Answers
2
You can use something like this
public static void setAutoOrientationEnabled(Context context, boolean enabled)
{
Settings.System.putInt( context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0);
}
dont forget to add permissons
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
for more details you can see this

Maniya Joe
- 761
- 6
- 24
0
Set orientation permission in the manifest :
android:configChanges="orientation"
then enable the orientation by calling setRequestedOrientation
:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

sak
- 1,230
- 18
- 37

Slimane amiar
- 934
- 12
- 27