Android 打开屏幕旋转

添加设置读写权限:java

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

判断是否屏幕旋转被关闭,若是关闭则打开:android

// check whether the screen rotation works
    int flag = Settings.System.getInt(getContentResolver(),
        Settings.System.ACCELEROMETER_ROTATION, 0);
    if (0 == flag) {
      // open screen rotation and give user infomation alert
      Toast.makeText(getApplicationContext(), "open screen rotation",
          Toast.LENGTH_LONG).show();
      Settings.System.putInt(getContentResolver(),
          Settings.System.ACCELEROMETER_ROTATION, 1);
相关文章
相关标签/搜索