Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does surfaceDestroyed() occur

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?

like image 482
Hani Honey Avatar asked Apr 09 '11 17:04

Hani Honey


2 Answers

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

like image 164
Lumis Avatar answered Sep 27 '22 23:09

Lumis


surfaceDestroyed() is not called when the view is managed by a TabHost.

like image 31
l33t Avatar answered Sep 27 '22 23:09

l33t