Original link: http://www.cnblogs.com/feidu/p/8057012.html
When Android launches activity across processes, the process interface is very black screen (white screen) for a short time (hundreds of milliseconds?). )。 Of course, the same thing happens when you start an app from desktop Lunacher, because the app cold start is also a cross-process startup activity. Why is this not happening? The real culprit is that the Android creation process requires a lot of resources to prepare, which is a time-consuming operation.
Black screen (white screen) cause
When a process initiates an activity in the B process, the Android system will have the zygote process create a B process before the activity can be started. However, the creation process is time-consuming, and the new activity interface has not yet been presented until the creation is complete, so the user is momentarily unresponsive when jumping to new activity, which greatly reduces the user experience.
The Android team avoids this embarrassed situation, so the system displays a white screen or a black screen depending on the theme color set by your manifest file. This black (white) screen is referred to as the preview window, which is the previews.
Solution Solutions
1. Disable Preview Window
Now that Android has set the preview Window by default when the creation process launches new activity, we can also disable the property in the topic.
Style.xml
<style name="APPTheme" parent="@android:style/Theme.Holo.NoActionBar"> <item name="android:windowDisablePreview">true</item></style>
Analysis: This can solve some of the problems of the scene, such as in a process to start B process activity, but in another scene has a problem, in the Desktop launcher Click Application There is a brief phenomenon of suspended animation.
2. Customizing the preview Window
Now that Android can set the preview Windo black screen (white screen) based on the theme, we can also customize a preview window style to replace the black (white) screen effect.
Style.xml
<style name="APPTheme" parent="@android:style/Theme.Holo.NoActionBar"> <item name="android:windowBackground">@drawable/splash_icon</item> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item></style>
Analysis: This solution is good for launching an app scene, the Android:windowbackground property sets the background of the preview window, and most apps on the market use this property to set the Start page background. For memory-saving considerations This background picture is suitable for use with simple effects. 9 images.
However, the solution is not suitable for launching activity scenarios across processes.
3. Set Preview window Transparency properties
We can set the preview Window to be transparent or solve the problem
Style.xml
<style name="APPTheme" parent="@android:style/Theme.Holo.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item></style>
Analysis: This solution is suitable for launching activity scenarios using across processes. Of course, this solution will also introduce other problems, namely:android:windowistranslucent caused activity Switch animation invalid solution . In order to pursue the Acme, cannot solve a problem to introduce a new problem, the solution of this problem also has two kinds:
<style name="APPTheme" parent="@android:style/Theme.Holo.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item> <item name="android:windowAnimationStyle">@styleAnimation.Activity.Translucent.Style/</item></style><style name="Animation.Activity.Translucent.Style" parent="@android:style/Animation.Translucent"> <item name="android:windowEnterAnimation">@anim/base_slide_right_in</item> <item name="android:windowExitAnimation">@anim/base_slide_right_out</item> </style>
Since then, three schemes have been given to launch the activity Black (white) screen across the process, crossing can use the different solutions according to different scenarios.
Scan code attention to the public number "Android knowledge spread ", not regularly spread the basic knowledge of commonly used Android.
Three solutions for Android to launch activity black screen (white screen) across processes