Back to project page SimpleReader.
The source code is released under:
Apache License
If you think the Android project SimpleReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dreamteam.app.ui; //from w ww .java 2 s . co m import android.annotation.SuppressLint; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.os.Handler; import android.os.Message; import com.dreateam.app.ui.R; public class SplashActivity extends Activity { boolean isFirstIn = false; private static final int GO_HOME = 1000; private static final int GO_GUIDE = 1001; // ??3? private static final long SPLASH_DELAY_MILLIS = 2000; private static final String SHAREDPREFERENCES_NAME = "first_pref"; /** * Handler:???????????? */ @SuppressLint("HandlerLeak") private Handler mHandler = 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); Intent intent = getIntent(); if (intent != null) { String title = intent.getStringExtra("section_title"); if (title != null) { intent.setClass(this, ItemListActivity.class); startActivity(intent); } } setContentView(R.layout.splash_acitvity); init(); } private void init() { // ????SharedPreferences????????? // ??SharedPreferences????????????? SharedPreferences preferences = getSharedPreferences( SHAREDPREFERENCES_NAME, MODE_PRIVATE); // ????????????????????????true????? isFirstIn = preferences.getBoolean("isFirstIn", true); // ????????????????????????????????????????????? if (!isFirstIn) { // ??Handler?postDelayed???3?????????MainActivity mHandler.sendEmptyMessageDelayed(GO_HOME, SPLASH_DELAY_MILLIS); } else { Editor editor = preferences.edit(); editor.putBoolean("isFirstIn", false); editor.commit(); mHandler.sendEmptyMessageDelayed(GO_GUIDE, SPLASH_DELAY_MILLIS); } } private void goHome() { Intent intent = new Intent(SplashActivity.this, MainActivity.class); SplashActivity.this.startActivity(intent); SplashActivity.this.finish(); } private void goGuide() { Intent intent = new Intent(SplashActivity.this, GuideActivity.class); SplashActivity.this.startActivity(intent); SplashActivity.this.finish(); } }