Android 2.2.1、方向更改和 onDestroy()

发布于 2024-11-05 12:20:11 字数 319 浏览 3 评论 0原文

我有一个非常令人发指的错误,我正在尝试找出它,并且遇到以下情况。

这是我的场景,我启动一个活动,将屏幕方向更改为横向,然后再次将其更改回纵向,然后单击设备后退按钮。在我这样做之后,我的活动的 onDestroy 永远不会被调用。当我改变方向时会调用它,但当用户按后退键时不会调用它。

  1. 它仅发生在 Android 2.2.1 上,且调试器未连接时。
  2. 它涉及更改屏幕方向。
  3. onDestroy 在屏幕方向后永远不会被调用。

我在这里束手无策,我正在寻找关于什么可以阻止系统调用 onDestroy 的想法......

I have a really heinous bug that I'm trying to track down and I've got the following situation.

Here's my scenario, I launch an activity, I change screen orientation to landscape, I change it again back to portrait, then I click on the device back button. After I do that, onDestroy of my activity is never called. It's called when I change orientation, but not when the user hits the back key.

  1. it only happens on Android 2.2.1 while debugger is not connected.
  2. it involves changing the screen orientation.
  3. onDestroy is never called after a screen orientation.

I'm at my wits end here and i'm looking for ideas on what could prevent the system from calling onDestroy...

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

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

发布评论

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

评论(1

不可一世的女人 2024-11-12 12:20:11

Android docs 状态

Note: do not count on this method being called as a place for saving data! For example, if an        
activity is editing data in a content provider, those edits should be committed in either onPause() or
onSaveInstanceState(Bundle), not here. 

如果您还查看Activity 生命周期中的可杀死列,在前蜂巢系统上,应用程序可以在 onPause 之后的任何时间点被系统杀死,无论出于何种原因。

Android docs state

Note: do not count on this method being called as a place for saving data! For example, if an        
activity is editing data in a content provider, those edits should be committed in either onPause() or
onSaveInstanceState(Bundle), not here. 

If you also look at the Killable column in the activity life cycle, the application can be killed by the system at any point after onPause on pre-honeycomb systems for whatever reason.

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