My SurfaceView is not destroyed even if onPause triggers an action.
I care about the flow in
public void surfaceCreated(SurfaceHolder holder) { if (mGameThread.getState() == Thread.State.TERMINATED) { createGameThread(getHolder(), getContext()); } mGameThread.setRunning(true); mGameThread.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; mGameThread.setRunning(false); while (retry) { try { mGameThread.join(); retry = false; } catch (InterruptedException e) { } } }
As a hack, I have to check the state of the thread in onResume, and if the thread has already completed, I would end the action
protected void onResume() { Log.d(mLogTag, "onResume()"); super.onResume(); if (mGameThread != null) { if (mGameThread.getState() == Thread.State.TERMINATED) { finish(); } } }
Unfortunately, it is not possible to move thread processing from the Destroyed and surfaceCreated surfaces to onPause () and onResume () activity. Is it possible to manually destroy SurfaceView in onPause () and recreate it in onResume ()?
source share