我有一个应用程序,我希望我的应用程序尊重轮换荣誉。但是如何检查旋转是否在 Android 上被锁定?当然以编程方式:)
==================
感谢伊姆兰的回答。我再次放在这里是因为我找不到有关 DEFAULT_ACCELEROMETER_ROTATION 的任何信息,而且如果您只想读取系统设置,也不需要更改用户权限。干杯!
http://developer.android.com/reference/android/provider/Settings.System.html#getInt(android.content.ContentResolver , java.lang.String)
int str = Settings.System.getInt(Context.getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION);
??????? K 解决方案有效,但此回复是一个更漂亮且固定的解决方案:
boolean isOrientationEnabled;
try {
isOrientationEnabled = Settings.System.getInt(getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION) == 1;
} catch (SettingNotFoundException e) {
isOrientationEnabled = false;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3342 次 |
| 最近记录: |