The example of this article describes the Android simple implementation of the splash screen method. Share to everyone for your reference, specific as follows:
Core code:
Package Com.demo.app;
Import android.app.Activity;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.os.Handler;
public class Splashactivity extends activity {
private final int splash_display_lenght = 6000;//delay six seconds
@Override
protected void OnCreate (Bundle savedinstancestate) {
super.oncreate (savedinstancestate);
Setcontentview (R.layout.splash);
New Handler (). postdelayed (New Runnable () {public
void run () {
Intent mainintent = new Intent ( Splashactivity.this,
helloworldactivity.class);
SplashActivity.this.startActivity (mainintent);
SplashActivity.this.finish ();
}
, splash_display_lenght);
}
Description
Handler (). Postdelayed is deferred for a specified time
The handler class can mainly use the following 3 methods to set the time to execute the Runnable object:
Immediately executes the Runnable object public
Final Boolean post (Runnable R);
Executes the Runnable object public
Final Boolean postattime (Runnable R, Long Uptimemillis) at the specified time (uptimemillis);
Executes the Runnable object public
Final Boolean postdelayed (Runnable R, Long Delaymillis) at the specified time interval (delaymillis);
The following two lines of code start a new activity and close the current activity.
SplashActivity.this.startActivity (mainintent);
SplashActivity.this.finish ();
For more information on Android-related content readers can view the site: "The activity of Android programming skills Summary", "Android Resources Operating Skills Summary", "Android File Operating skills summary", " Android Operation SQLite Database skills Summary, "Android operation JSON format Data Skills summary", "Android Database Operation skills Summary", "Android programming development of SD card Operation Summary", "Android Development introduction and Advanced Course", The Android View view tips summary and the Android Control usage summary
I hope this article will help you with the Android program.