×
您的位置: 首页 > 编程笔记

什么时候surfaceDestroyed()出现(When does surfaceDestroyed() occur)

Android 时间:2020-06-15  查看:777   收藏

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?

解决方案

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

我无法搞清楚当 surfaceDestroyed()出现。我试图让我的线程停在 surfaceDestroyed()运行方法(一SurfaceView),但现在看来,我的面从来没有真正破坏......谁能告诉我当这种情况发生?或者如何引发的?

解决方案

每当你点击返回或home键,让你得到活动:

活动的onPause

surfaceDestroyed

和最后活动onDestroyed。

当您返回surfaceView被重建,但是如果你一直在使用静态变量也驱动应用程序,他们会常常preserved,它可能只是看起来像surfaceView没有被破坏。

关于关闭线程,看看这个:Android当应用程序被关闭并重新打开

崩溃

 

0% (0)
0% (0)