i found that this codes will cause surfaceCreated and surfaceDestroyed to be called several times:
mSurfaceView.setVisibility(View.GONE);
mSurfaceView.setVisibility(View.VISIBLE);
could anybody tell me why surfaceCreated and surfaceDestroyed doesn't to be called only once ?
If you implement SurfaceHolder.Callback
and put a logger inside each of surfaceDestroyed
, surfaceCreated
, surfaceChanged
methods, you will see that those two lines will generate the following output:
04-01 12:50:54.688: INFO/app(4842): SurfaceView destroyed!
04-01 12:50:54.688: INFO/app(4842): SurfaceView created!
04-01 12:50:54.718: INFO/app(4842): SurfaceView changed!
Using two breakpoints before and after the calls to setVisibility
, just make sure you don't count other logs.