本文介绍了什么时候surfaceDestroyed()出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

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

Whenever you click return or home button and leave the activity you get:

活动的onPause

Activity onPause

surfaceDestroyed

surfaceDestroyed

和最后活动onDestroyed。

and finally activity onDestroyed.

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

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.

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

Regarding closing the thread, check this: Android crash when app is closed and reopened

这篇关于什么时候surfaceDestroyed()出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 06:11