有很多很酷的小部件可以在手机上启用和禁用自动旋转。禁用它会在手机上的所有应用程序中关闭它。
他们如何实现这一目标有什么想法吗?
这应该可以为你解决问题:
import android.provider.Settings;
public static void setAutoOrientationEnabled(Context context, boolean enabled)
{
Settings.System.putInt( context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0);
}
在AndroidManifest.xml中添加权限
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
你可以找到文档here http://developer.android.com/reference/android/provider/Settings.System.html#ACCELEROMETER_ROTATION
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)