Skip to content Skip to sidebar Skip to footer

How To Pause A Surfaceview Thread From An Android Activity

I have followed this tutorial in great detail and have managed to understand and replicate the functions that I need from an Android SurfaceView: http://obviam.net/index.php/moving

Solution 1:

My opinion to you would be not to pause the thread when the virtual pause button in the game has been pressed, yet rather just alter your update method: eg

if(paused == true) {
// Don't do anything 


} 
else {
// Play
}

Yet to pause a your rendering thread, you can invoke the join() method on the thread.

I hope this helps.

Solution 2:

I figured out a simple way to bypass the problem.

All I did was got the pause button to call an activity over the Surfaceview and hence it would pause the view. Then when I close that activity the thread continues from where it left off.

Post a Comment for "How To Pause A Surfaceview Thread From An Android Activity"