Android - 滑块设备导致 Activity 重置

发布于 2024-09-14 21:28:15 字数 359 浏览 2 评论 0原文

在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作妖 2024-09-21 21:28:15

这是 Android 中推荐的行为。但如果您想停止此操作,您可以在清单中针对您的活动指定以下属性

android:configChanges="keyboardHidden|orientation"

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

android:configChanges="keyboardHidden|orientation"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文