Almost all Android applications will have a splash screen, display their own logo, this version of the information, or a bit more humane, in a very long loading information, change some of the display of text, etc., so that the boring wait time to add a bit of flavoring agent.
Specifically, you should create an activity with no title, display pictures, text. It creates new threads to load data, detects good devices, etc., and launches new activity when everything is ready.
The code is as follows
Androidmanifast.xml
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.dnfscripts"Android:versioncode= "1"Android:versionname= "1.0" > <USES-SDKandroid:minsdkversion= "8"android:targetsdkversion= "8" /> <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" > <ActivityAndroid:name= "Com.example.dnfscripts.LoadActivity"Android:theme= "@android: Style/theme.notitlebar"> <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> <ActivityAndroid:name= "Com.example.dnfscripts.MainActivity"Android:label= "@string/app_name" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> </Application></Manifest>
Among them, declare two activity, one is used as the splash screen, the other one is the main screen that is displayed after booting.
android:screenorientation= "Portrait"//Screen always portrait
"Landscape"//Screen always landscape
Android:theme= "@android: Style/theme.notitlebar"//Screen has no title bar
Load.xml
&NBSP;
< linearlayout xmlns:android = "http://schemas.android.com/apk/res/android" android:orientation = "vertical" android:gravity = "Center|center" = "Fill_parent" = "Fill_parent" = "@drawable/index" </ linearlayout >
The load.xml is a style expression that initiates activity, where
android:background= "@drawable/load"//Set Load.png picture as background map
Loadactivity.java
Packagecom.example.dnfscripts;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.graphics.PixelFormat;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.view.ContextMenu;ImportAndroid.view.ContextMenu.ContextMenuInfo;ImportAndroid.view.View;ImportAndroid.view.Window;ImportAndroid.view.WindowManager; Public classLoadactivityextendsActivity {Private Static Final intLoad_display_time = 5000; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); GetWindow (). SetFormat (pixelformat.rgba_8888); GetWindow (). Addflags (WindowManager.LayoutParams.FLAG_DITHER); Setcontentview (R.layout.activity_load); NewHandler (). postdelayed (NewRunnable () {@Override Public voidrun () {/*Create an Intent that'll start the Main WordPress Activity.*/Intent mainintent=NewIntent (loadactivity. This, Mainactivity.class); Loadactivity. This. StartActivity (mainintent); Loadactivity. This. Finish (); }},load_display_time); //For release} @Override Public voidOncreatecontextmenu (ContextMenu menu, View V, contextmenuinfo menuinfo) {//TODO auto-generated Method Stub Super. Oncreatecontextmenu (menu, V, menuinfo); }}
Among them, Handler (). postdelayed (Runnable R, Long Delaymillis)
Causes the Runnable R to is added to the message queue, to is run after the specified amount of time elapses.
The code now only implements a very simple display of the load page.
"Android" app splash screen