Make Android app startup more coordinated

Source: Internet
Author: User
I don't know if anyone has found that the application was generally slow when it was started for the first time (especially for low-configuration mobile phones). The black screen is good for a while. below is what I started QQ in the simulator, the black screen takes about 5 seconds, as shown in Figure ~


Obviously, this result is very bad, and the user experience is very poor. Is there any way to solve this problem? Some people may say that splash screen is used, but this is not reliable, it is not a solution to this problem. We all know that when you exit an application, the process of the application will not be killed and will reside in the background (possibly killed by the system), so that the next application can be started quickly. However, when an application is started for the first time or the process is killed and started again, a series of things need to be done. First, a process needs to be allocated, A Dalvik VM is instantiated in the process, and a virtual opportunity is then initiated to initialize the main UI thread. Although Android uses zygote technology, it takes some time to do this. To prevent application blocking and respond to users as soon as possible during this period, Android displays a temporary "starting"
Window "to the user, this window does nothing, can not get the focus and cannot process the user's touch.
After the application process is initialized, the system will remove the temporary window to display the application window and view. Before that, your application did not run any code. Now there is a problem. How does the system know what our application will look like? Is this "Starting "?
Window is always fixed and unchangeable. The original system will read it in androidmanifest when loading the application. the theme (Theme configured by application or activity) specified in XML determines the "Starting window" style. If theme is not configured, the default theme (@ Android: style/theme or @ andriod: style/theme. holo. light) will be used.
After some analysis above, we only need to monetize our theme and configure it on the application or activity to change the default "Starting
The appearance of window makes window switching between our applications more harmonious. Below is a theme demo I wrote, and you can specify this theme on the application node.
    <style name ="Theme.Starting.Window" parent= "@android:style/Theme.Holo.Light" >        <item name= "android:actionBarStyle">@style/StartingWindowActionBar</item >    </style >    <style name ="StartingWindowActionBar" parent= "@android:style/Widget.Holo.Light.ActionBar" >        <item name ="android:background"> #2E495E</ item>        <item name= "android:titleTextStyle">@style/StartingWindowActionBar.Text </item >    </style >    <style name ="StartingWindowActionBar.Text" parent= "@android:style/TextAppearance">        <item name ="android:textColor"> #FFA500</ item>    </style >



The comparison between the two results shows that the latter is more beautiful and harmonious. In fact, the "Starting window" will also be used for activity switching, but the time is usually very short and difficult to identify with the naked eye, so no corresponding processing is required.
More details: http://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/











Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.