[英]Android: How to force reverse portrait orientation even if the device auto-rotate screen is off?
[英]How to listen to screen orientation change when auto-rotate is disabled in Android?
在我的应用程序中,我禁用了自动定向,但是我仍然想听听定向更改方法。
我尝试覆盖onConfigurationChanged
但我猜想禁用自动旋转时不会调用它。
我建立在API 8上。
谢谢
我将看一下如何读取加速度计或陀螺仪。 我不确定这是否行得通,但这就是我的起点。 这是有关如何使用加速度计数据的链接。
http://www.techrepublic.com/blog/app-builder/a-quick-tutorial-on-coding-androids-accelerometer/472
我在我的应用中自己使用此代码:
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
int rotation = display.getRotation();
rotation
值可以如下:横向为1或3,纵向为0或2。
我不确定100%是否可以在禁用自动旋转功能的情况下工作,但是您可以尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.