即使设备方向锁定,应用程序也会自动旋转 [英] App auto rotates even with device orientation locked

查看:106
本文介绍了即使设备方向锁定,应用程序也会自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究基于正常活动的应用程序. 我已从设备设置中关闭了设备方向. 当我在设备上运行我的应用程序时,该应用程序会根据设备移动来更改方向. 我不知道即使锁定了设备方向,应用程序如何旋转. 堆栈溢出或任何其他论坛上均未报告或从未询问过此类实例/问题. 请指出,我可能会缺少什么?

I am working on normal activity based application. I have turned off device orientation from device settings. When I run my app on device, the app changes orientation based on device movement. I have no clue how can an app rotate even when device orientation is locked. There is no such instance/issue reported or ever asked on stack overflow or any other forum. Please point out, what I might be missing?

推荐答案

这是一个非常愚蠢的错误,但是我想到了在这里分享,以防其他人遇到此问题. 有时,在我的应用程序中,我通过编程将设备方向设置为SCREEN_ORIENTATION_FULL_SENSOR:

It was very silly mistake, but I thought of sharing here in case any one else faces this issue. At a point, in my application, I was setting device orientation programmatically to SCREEN_ORIENTATION_FULL_SENSOR:

activityContext.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

即使用户锁定了设备方向,这也允许应用根据传感器更改方向.

This allows app to change orientation, based on sensor, even when user has locked the device orientation.

这篇关于即使设备方向锁定,应用程序也会自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆