蜂窝方向变化

发布于 2024-11-28 00:59:17 字数 365 浏览 7 评论 0原文

我有一项活动在方向改变后不应重新创建。我将以下内容添加到清单中的活动声明中:

android:configChanges="orientation"

在 Android 2.3 上,这完美运行。在 HONEYCOMB_MR2 onCreate 上是改变方向时无论如何都会调用。

是否还需要在 HONEYCOMB_MR2 上执行其他操作以防止在方向更改后重新创建活动?

I have an activity that shouldn't be recreated after an orientation change. I added the following to the activity declaration in the manifest:

android:configChanges="orientation"

On Android 2.3 this works perfectly. On HONEYCOMB_MR2 onCreate is called anyway when change the orientation.

Is there something else that needs to be done on HONEYCOMB_MR2 to prevent recreating the activity after an orientation change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

甚是思念 2024-12-05 00:59:17

显然,使用 orientation|screenSize (?) 会阻止 Honeycomb 上的 onCreate 并且(到目前为止)似乎不会破坏以前的 Android 版本中的任何内容。

android:configChanges="orientation|screenSize"

不知道为什么这是必要的,而且我不太理解 文档 关于这个新值。

我怀疑在 HONEYCOMB_MR2 中,方向更改后,活动将其视为两个配置更改:方向和屏幕尺寸。默认情况下,两者都会尝试重新创建活动。

Apparently using orientation|screenSize (?) prevents onCreate on Honeycomb and (so far) does not seem to break anything in previous Android versions.

android:configChanges="orientation|screenSize"

No idea why this is necessary and I don't really understand the documentation about this new value.

I suspect that in HONEYCOMB_MR2 upon an orientation change the activity considers this as two config changes: orientation and screen size. And both attempt to recreate the activity by default.

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