Android - 滑块设备导致 Activity 重置
在使用 G1 在 Android 1.6 上进行测试时,我注意到当我滑出键盘时,它会终止 Activity 并重新创建它,即使我已将 Activity 设置为仅以纵向模式显示。
当我按回键盘时,也会发生同样的情况。
我会调用 onSaveInstance、onDestroy,然后调用 onCreate、onResume、OnrestoreInstance...
我明白为什么在显示切换到横向视图时会执行此操作,但为什么当我特别不这样做时会发生这种情况希望我的活动切换视图,它本质上是无缘无故地杀死并重新启动活动。
2.x 设备上也一样吗?
我是否缺少某些东西来阻止它发生?
谁能解释一下它是否有任何意义?
While testing on Android 1.6 using a G1 I have noticed that when I slide out the keyboard it kills the activity and recreates it even though I have set my activity to only display in portrait mode.
Same happens when I push the keyboard back in.
I get onSaveInstance, onDestroy called, then onCreate, onResume, OnrestoreInstance...
I understand why this is done when the display is being switched to landscape view but why does this happen when I specifically dont want my activity to switch view, its essentially killing and restarting the activity for no reason.
Is it the same on 2.x devices?
Is there something I'm missing to stop it happening?
Can anyone explain if there is any point to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Android 中推荐的行为。但如果您想停止此操作,您可以在清单中针对您的活动指定以下属性
This is the recommended behavior in Android. But if you want to stop this you can specify the following property in your Manifest against your Activity