获取自动旋转信息在​​Android上信息、Android

2023-09-07 17:45:44 作者:梦里七彩虹

我正在为Android应用程序,因为我想知道自动旋转是否启用。有谁知道我能得到这个?所以,仅仅是为了清楚:我只需要知道用户是否已经在其设置中启用与否自动旋转

I am working on an app for Android, for which I would like to know whether or not Auto-Rotate is enabled. Does anybody know how I can get this? So just for clarity: I only need to know whether or not a user has Auto-Rotate enabled in their settings or not.

推荐答案

您可以自动旋转方式开启/关闭使用 Settings.System.ACCELEROMETER_ROTATION 为:

You can Get Auto-Rotate Information On/Off Using Settings.System.ACCELEROMETER_ROTATION as :

if (android.provider.Settings.System.getInt(getContentResolver(),Settings.System.ACCELEROMETER_ROTATION, 0) == 1){
 Toast.makeText(Rotation.this, "Rotation ON", Toast.LENGTH_SHORT).show();

}
else{
 Toast.makeText(Rotation.this, "Rotation OFF", Toast.LENGTH_SHORT).show();
}