surfaceDestroyed()何时发生
我无法确定 surfaceDestroyed()
何时发生。我试图让我的线程停止在(SurfaceView 的)surfaceDestroyed() 方法中运行,但似乎我的表面从未真正被破坏......有人可以告诉我何时发生这种情况吗?或者说如何触发?
I'm having trouble figuring out when surfaceDestroyed()
occurs. I am trying to make my threads stop running in the surfaceDestroyed()
method (of a SurfaceView) but it appears that my surface is never actually destroyed...can someone tell me when this happens? Or how to trigger it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当您单击返回或主页按钮并离开 Activity 时,您都会得到:
Activity onPause
surfaceDestroyed
和最后的 Activity onDestroyed。
当您返回时,SurfaceView 会重新创建,但是如果您一直使用静态变量来驱动应用程序,它们通常会被保留,并且可能看起来 SurfaceView 没有被破坏。
关于关闭线程,请检查以下内容:应用程序时Android崩溃已关闭并重新开放
Whenever you click return or home button and leave the activity you get:
Activity onPause
surfaceDestroyed
and finally activity onDestroyed.
When you return the surfaceView is recreated, however if you have been using static variables do drive the application, they will be often preserved and it may only seem like surfaceView was not destroyed.
Regarding closing the thread, check this: Android crash when app is closed and reopened
当视图由
TabHost
管理时,不会调用surfaceDestroyed()
。surfaceDestroyed()
is not called when the view is managed by aTabHost
.