Android Project Combat (42): Start Page optimizer, remove short white screen or black screen

Source: Internet
Author: User

Original: Android Project Combat (42): Start Page optimizer, remove short white screen or black screen

You will find an empty item that opens the app from the mobile desktop is the second boot. But for the projects that you develop, sometimes you will find that when you open the app, there will be a short 1 seconds-2 seconds of white screen or black screen, and then go to the program interface.

Personal understanding for our own implementation of the application file inside do a lot of initialization, when these initialization operations to enter the first activity, this initialization time because there is no interface, the application will be due to the category of the subject Display white screen or black screen.

  

The reason codes that make up the white screen/black screen are as follows:

/**
* @author XQX
* @email [email protected]
* blog:http://www.cnblogs.com/xqxacm/
* Createat 2017/1/30
* Description: Perform third-party initialization and other operations
*/
 Public classXapplication extends application{@Override Public voidonCreate () {super.oncreate ();//Ring-Letter initialization//easeui.getinstance (). Init (this,null);//emclient.getinstance (). Setdebugmode (True); //Friends League statistics general statistics scene typeMobclickagent.setscenariotype ( This, Mobclickagent.escenariotype.        E_um_normal); //disables the default page statistics so that activity is no longer automatically counted. Mobclickagent.openactivitydurationtrack (false) ; //Log EncryptionMobclickagent.enableencrypt (true);//6.0. Version 0 and later//Error Log StatisticsMobclickagent.setcatchuncaughtexceptions (true); //page Access Path statisticsMobclickagent.openactivitydurationtrack (true); //AuroraJpushinterface.setdebugmode (true); Jpushinterface.init ( This);
    
  /.... Various three-party initialization }

Workaround, set a separate theme for the first activity of the app, typically the first activity is the start page.

We just have to write a theme in the Res/values/styles.xml file that inherits from the theme of our app.

  

<!--Base Application theme. -<!--the theme of the app. -<style Name="Apptheme"Parent="Theme.AppCompat.Light.DarkActionBar"> <!--Customize your theme here. -<item Name="colorprimary"> @color/colorprimary</item> <item name="Colorprimarydark"> @color/colorprimarydark</item> <item name="coloraccent"> @color/coloraccent</item> </style><!--Start Page activity theme, to solve the 1-2-second white screen when the problem, inherit from the theme of the application, only need to apply the first activity to set this topic, generally start page--<style name="Myguidetheme"Parent="Apptheme"> <!--Customize your theme here. -<item Name="android:windowistranslucent">true</item> <item name="Android:windownotitle">true</item> </style>

  

Then, in the Androidmanifest.xml file, set this topic to the startup page.

  

<Activity Android:name=". Ui.moduleLogin.GuideActivity"android:configchanges="orientation|keyboardhidden|screensize"android:screenorientation="Portrait"android:theme= "@style/myguidetheme"//This activity sets the theme individually> <intent-filter> <action android:name="Android.intent.action.MAIN"/> <category android:name="Android.intent.category.LAUNCHER"/> </intent-filter> </activity>

  

  Note:1, This workaround will have a bug where the activity of the theme is set on the small model, and if the user goes to the recent list (press and hold the home key or press the menu key) there will be a flicker problem.

So we can not set the entire theme of the application to this, only need to start the page settings, because the start page only a few 1-2 seconds to enter the main interface, the user into the most recent list of the trigger is very low, experience better.

2, if the application in the initialization of a lot of things, longer, such as more than 2 seconds, this method is not applicable, will cause the user to click Icon2 seconds after the app opened, the user experience is poor.

Android Project Combat (42): Start Page optimizer, remove short white screen or black screen

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.