setRequestedOrientation 更改全局系统方向首选项
大家晚上好。
简单的问题
为什么
mActivity.setRequestedOrientation(force ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
要从设备的快速设置图标打开“自动旋转”? 似乎 setRequestedOrientation() 会全局更改系统首选项,无论名为 setRequestedOrientation 的活动是否正在运行。
good evening people.
Simple question
why
mActivity.setRequestedOrientation(force ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
turns 'auto rotate' from device's quick settings icon ON ?
seems like setRequestedOrientation() globally changes system preference regardless activity which called setRequestedOrientation is running or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我敢打赌,它是由制造商修改的 Android 版本的一些附加“功能”或行为。检查来自不同制造商或至少不同 Android 版本的其他设备。你也可以尝试使用模拟器
我有一些带有干净Android版本的旧平板电脑,其陀螺仪/加速计已损坏,设备重置后只能工作几个小时。所以我禁用了自动旋转并在其上设置了固定的水平方向。仍然当我使用与您的类似代码强制纵向模式运行我的应用程序时,它将按预期以纵向模式显示,但是当我退出我的应用程序时,整个界面/以前的应用程序以水平方式运行 - 仍然没有启用自动旋转选项
I bet its some additional "feature" or behavior of your Android version modified by manufacturer. check on some other device from different manufacturer or at least different Android version. you can also try to use emulator
I have some old tablet with clean Android version, which have broken gyro/accelerometer, works only for few hours after device reset. so I've disabled auto-rotate and set fixed horizontal orientation on it. still when I run my app with similar code to yours forcing portrait mode then it will show in portrait mode as intended, but when I exit my app then whole interface/previous app runs in horizontal - still no auto-rotate option enabled