滑出式键盘手机上的固定方向活动生命周期
我的清单中有一个具有固定方向的 Activity
,android:screenOrientation="portrait"
。我注意到,当在模拟器上按 Cntl-F11 以及用户在设备上滑出键盘时,Activity
会被销毁,并且 onCreate
会被调用。
然而,当我使用非滑出键盘设备时,Activity
永远不会被破坏,仅仅是因为它被锁定为纵向。
为什么设备之间的行为存在差异?为什么锁定纵向的 Activity 会调用配置更改?这真是令人恼火。
编辑:我还尝试了android:configChanges="orientation
,没有任何明显的差异。
I have an Activity
with a fixed orientation, android:screenOrientation="portrait"
in my manifest. I noticed that when pressing Cntl-F11 on the emulator and when a user slides out the keyboard on a device the Activity
is destroyed and onCreate
is called.
Yet when I use a non-slide out keyboard device the Activity
is never destroyed, simply because it is locked to portrait.
Why is there a difference in behavior between devices? Why is an Activity that is locked to portrait, invoking a configuration change? This is really irritating.
Edit: I also experimented with android:configChanges="orientation
without any noticeable difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 configChanges 属性。
然而,这难道没有指出为什么强制应用程序处于纵向模式是一个坏主意吗?这对于带有键盘的手机来说确实很烦人。
You can probably prevent this by telling Android you want to handle the configuration changes yourself via the configChanges attribute.
However, doesn't this point out why it is a bad idea to force the app to be in portrait? That is really annoying on phones with a keyboard.