Imitation, the first time to go to the boot interface, otherwise into the boot interface.
Package edu.hpu.init;
import EDU.HPU.LOGIC.R;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import Android.os.Bundle;
import Android.os.Handler;
import android.os.Message;
Public class extends Activity {
Boolean false;
Private Static Final int Go_home = 1000;
Private Static Final int Go_guide = 1001;
3 seconds delay
Private Static Final long delaytime = 3000;
Private Static Final String spname = "first_pref";
Private New Handler () {
@Override
Public void handlemessage (Message msg) {
Switch (msg.what) {
Case Go_home:
GoHome ();
break;
Case Go_guide:
Goguide ();
break;
}
Super. Handlemessage (msg);
}
};
@Override
protected void onCreate (Bundle savedinstancestate) {
Super. OnCreate (savedinstancestate);
Setcontentview (R.layout.splash);
Init ();
}
Private void init () {
Read the data needed in the Sharedpreferences
Use Sharedpreferences to record the number of programs used
Interface, mode_private specifies that the sharedpreferences data can only be read and written by this application
Sharedpreferences preferences = Getsharedpreferences (
Spname, mode_private);
Editor = Preferences.edit ();
Gets the corresponding value, if there is no value, the description is not written, with true as the default value
Isfirstin = Preferences.getboolean ("isfirstintrue");
Determine the number of times the program runs, if it is the first time to jump to the boot interface, otherwise jump to the main interface
if (!isfirstin) {
Mhandler.sendemptymessagedelayed (Go_home, delaytime);
Else {
Using Handler's Postdelayed method, execute guideactivity after 3 seconds
Mhandler.sendemptymessagedelayed (Go_guide, delaytime);
Editor.putboolean ("isfirstinfalse");
Editor.commit ();
}
}
Private void GoHome () {
New Intent (This, startactivity. Class);
StartActivity (Intent);
this. Finish ();
}
Private void goguide () {
New Intent (This, guideactivity. Class);
StartActivity (Intent);
this. Finish ();
}
}