从代码设置屏幕自动旋转系统设置

时间:2012-10-18 13:00:56

标签: android

我正试图弄清楚如何以编程方式修改此设置。有人可以指出API或提出建议吗?

图片说明了此选项在Android中的位置:

enter image description here enter image description here

2 个答案:

答案 0 :(得分:4)

检查此链接

http://developer.android.com/reference/android/provider/Settings.System.html#ACCELEROMETER_ROTATION

这是你的代码

android.provider.Settings.System.putInt(getContentResolver(),
android.provider.Settings.System.ACCELEROMETER_ROTATION,1);

Manifest需要此权限

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

答案 1 :(得分:-1)

如果您要执行的操作是将应用程序锁定在特定的屏幕方向,则可以使用活动清单中的android:screenOrientation属性。

请参阅here