In recent projects, one activity has been used in Fragment+viewpager, and one of the fragment implements the video playback function, including Surfaceview. As a result, each time the program is opened the first time it enters the activity, it will splash the screen black. The reason is Surfaceview.
Detailed
I think I found the reason for the black Flash. In my case I ' m using a surfaceview inside a Fragment and dynamically adding this Fragment to the activity after some actio N. The moment when I add the fragment to the activity, the screen flashes black. I checked out Grepcode for the Surfaceview source and here's what I found:when the surface view appears in the window the Very fist time, it requests the window ' s parameters changing by calling a private Iwindowsession.relayout (..) method. This method "gives" you a new frame, window, and window surface. I think the screen blinks right at that moment.
The solution is pretty simple:if your window already have appropriate parameters it won't refresh all the window ' s stuff and the screen would not blink. The simplest solution is to add a 0px height plain surfaceview to the first layout of your activity. This would recreate the window before the activity is shown on the screen, and if you set your second layout it would just Continue using the window with the current parameters. I hope this helps.
Reason:
Surfaceview because it is different from the general view, it has its own good buffering and data access mechanism, the system has special treatment for him. When Surfaceview the first time in the current activity add, the system will give WindowManager layout, relayout, so it will be black, this will only appear in the first time, and then add Surfaceview will not be black screen.
Solve:
Can be in the interface without entering the Surfaceview (such as a lot of programs in the loading interface), In other interface Layout.xml file add a surfaceview, width and height are made into 0DP, so that the layout has no impact, and this thing makes Surfaceview first appeared, then that is, the next time we really use the surfaceview will not splash screen.
How Android avoids the splash screen when switching to surfaceview (black screen flash)