I tried to add a VideoView to a layout dynamic via code in my Android app, but the whole screen flashes when the VideoView was added first time. To make the problem simple, I changed the VideoView to SurfaceView, as VideoView extends SurfaceView, you know, but the issue was still there.
After all, I found out the Window was destroyed then re-created when the SurfaceView was adding, and the Window's pixel format was changed mean while, that guided me to the answer, the pixel format of the SurfaceView and the Activity was different so Window Manager forced the re-created.
To resolve it, just added online in Activity:onCreate() to set pixel format, as below:
getWindow().setFormat(PixelFormat.TRANSLUCENT);
Thanks! :)
ReplyDelete