Android:垂直到水平旋转时暂停
我怎么能做这样的事情 - 当你将屏幕从水平旋转到垂直应用程序设置在暂停时(并显示屏幕,据说你应该垂直旋转屏幕以继续等)?
或者我如何才能禁用屏幕旋转?
How could I make such thing - when you rotate screen from horizontal to vertical application set on pasue (and show screen where is said that you should to rotate screen in vertical to continue e.t.c)?
Or how I can just disable screen rotation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将屏幕方向设置为纵向或横向(具体取决于根据您的要求)在 Android 清单文件中。
然后根据需要监听加速度计事件。
查看此问题。
Set the screen orientation to portrait or landscape (depending on your requirements) in the Android manifest file.
Then listen to the Accelerometer events if required.
See this question.
我相信您正在寻找的答案是在 Android 应用程序的 Activity 生命周期中。
我找到了这个链接并立即浏览。
如何在 Android 上禁用方向更改?
编辑:从那里我可以看到,需要做的就是修改
android 清单文件以将其包含在您的 Activity 中
在您的 MainActivity 中,应将其包含在内
<前><代码>@Override
公共无效onConfigurationChanged(配置newConfig){
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
I believe the answer you are looking for is in the activity life cycle of android apps.
I found this link and browsing it now.
How do I disable orientation change on Android?
edit: from there I can see that all that needs to be done is modify
android manifest file to include this in your activity
inside your MainActivity this should be included