问题描述
当我第一次开始我的android活动的onCreate()
被调用,那么 onResume()
。
When I start my android-activity first onCreate()
is called, then onResume()
.
当我再preSS后退按钮返回到主屏幕,并再次点击应用程序图标,第一个的onCreate()
被调用,那么 onResume()
然后的onDestroy()
。
When I then press the back-button to return to the home-screen and tap the app-icon again, first onCreate()
is called, then onResume()
and then onDestroy()
.
我的应用程序仍然处于活动状态,然后,做一些操作导致错误,因为的onDestroy()
设置了几个成员为null。
My app is still active then, but doing some action result in error since onDestroy()
sets a few members to null.
这是为什么?
更新::当我之后pressing等待30秒回一切工作正常。我没有做任何事情在沉重的onDestroy除了设置几个变量为空和 .interrupt()
ING后台线程。
Update: When I wait 30 seconds after pressing back everything works fine. I'm not doing anything heavy in onDestroy except setting a few variables to null and .interrupt()
ing a background-thread.
推荐答案
我自己想通了这一点。我多么活动的理解
是有缺陷。当然,Android的调用的onDestroy()的老 活动
实例,它可以发生几秒钟的之后的在新一个已经建成。
Figured this out by myself. My understanding of what an Activity
is was flawed. Of course Android calls onDestroy() on the old Activity
instance, which can happen several seconds after the new one has been constructed.
这篇关于使用后退按钮时,onResume()后为什么的onDestroy()称为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!