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:
- Log upload of logs;
- Skip to Main Page
- 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:
- Upload of log information;
- Initialization of resources (your own experience – Copy the contents of the Assets folder to an SD card when Splash animation jumps)
Detailed Introduction
- appstart.java--entrance to the entire application
- loguploadservice.java--in AppStart, complete the last log upload in the local
- 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:
- Start service, upload log;
- 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
- 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