Android Judgment Interface

Source: Internet
Author: User

Imitation, the first time to go to the boot interface, otherwise into the boot interface.

 Package edu.hpu.init;
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 () {
 Public void handlemessage (Message msg) {
Switch (msg.what) {
 Case Go_home:
GoHome ();
 Case Go_guide:
Goguide ();
Super. Handlemessage (msg);
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 ();
Related Article

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: 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.