Open source Chinese source Learning (ii)--splash interface

Source: Internet
Author: User

Today, we mainly learn the splash interface of open source China application launch.

Feature Description:

When the app launches, there is a launch welcome screen that completes the task in this interface:

  1. Log upload of logs;
  2. Skip to Main Page
  3. Animation--Perform both of these actions at the end of the animation
Integration Guide:

When you develop your own application, the splash interface can be used to do some initialization work, such as:

  1. Upload of log information;
  2. Initialization of resources (your own experience – Copy the contents of the Assets folder to an SD card when Splash animation jumps)
Detailed Introduction
    1. appstart.java--entrance to the entire application
    2. loguploadservice.java--in AppStart, complete the last log upload in the local
    3. Main interface of mainactivity.java--program
AppStart Analysis

In AppStart with an animation to control the image in the splash interface elegant display, at the end of the animation, complete two actions:

  1. Start service, upload log;
  2. Jump to the main program interface.
Loguploadservice Analysis--Start service

Start the service with the following code, which needs to be configured in the Mainfest file

    //在Mainfest文件中进行配置  <service android:name="net.oschina.app.LogUploadService"//启动Servicenew Intent(this, LogUploadService.class); startService(uploadLog);

Loguploadservice Learn more in the next article

mainactivity Analysis--Display the main interface

Start the main interface activity with the following code, which needs to be configured in the Mainfest file.

Configuration in the main interface<activityandroid:name=". UI. Mainactivity "android:launchmode="singletask "android:screenorientation=" Portrait " >                                                <intent-filter>                <action android:name="Android.intent.action.VIEW" />                <category android:name="Android.intent.category.BROWSABLE" />                <category android:name="Android.intent.category.DEFAULT" />                <dataandroid:host="www.oschina.net"android:scheme="http" / >                                                    </intent-filter>            <intent-filter>                <action android:name="Android.intent.action.VIEW" />                <category android:name="Android.intent.category.BROWSABLE" />                <category android:name="Android.intent.category.DEFAULT" />                <dataandroid:host="www.oschina.net"android:scheme="https " />                                                    </intent-filter>            <intent-filter>                <action android:name="Android.intent.action.VIEW" />                <category android:name="Android.intent.category.BROWSABLE" />                <category android:name="Android.intent.category.DEFAULT" />                <dataandroid:host= "my.oschina.net"android:scheme=" http " />                                                    </intent-filter>            <intent-filter>                <action android:name="Android.intent.action.VIEW" />                <category android:name="Android.intent.category.BROWSABLE" />                <category android:name="Android.intent.category.DEFAULT" />                <dataandroid:host="my.oschina.net"android:scheme="https" / >                                                    </intent-filter>        </activity>Start the main interface Intent Intent = new Intent (this, mainactivity.class); StartActivity (Intent);
Summarize the Harvest
  1. Start the service in the splash interface and upload log logs.
So far, it's not quite clear where
    • There is a code in the OnCreate method that prevents a third-party jump from appearing in a double instance, and it is not quite clear what it means, the code is as follows:
            // 防止第三方跳转时出现双实例        Activity aty = AppManager.getActivity(MainActivity.class);        ifnull && !aty.isFinishing()) {            finish();        }
    • There are a series of actions in the Onresume, still do not understand why:
  @Override  protected  void  onresume  () {super . Onresume (); int  cacheversion = preferencehelper.readint (this , ,  "First_install"  ,-1 ); int  CurrentVersion = Tdevice.getversioncode (); if  (Cacheversion < CurrentVersion) {Preferencehelper.write (this ,  "First_install" ,  "First_install" , CurrentVersion); Cleanimagecache (); } }

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Open source Chinese source Learning (ii)--splash interface

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.