标签:android style class c tar ext
仿造微信,第一次进入去引导界面,否则进启动界面。
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 TellActivity extends Activity {boolean isFirstIn = false;private static final int GO_HOME = 1000;private static final int GO_GUIDE = 1001;// 延迟3秒
private static final long delayTime = 3000;private static final String spName = "first_pref";private Handler mHandler = new Handler() {@Overridepublic void handleMessage(Message msg) {switch (msg.what) {
case GO_HOME:
goHome();break;
case GO_GUIDE:
goGuide();break;
}super.handleMessage(msg);
}};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.splash);init();}private void init() {// 读取SharedPreferences中需要的数据
// 使用SharedPreferences来记录程序的使用次数
//接口,MODE_PRIVATE指定该SharedPreferences数据只能被本应用程序读、写
SharedPreferences preferences = getSharedPreferences(spName, MODE_PRIVATE);SharedPreferences.Editor editor;editor = preferences.edit();// 取得相应的值,如果没有该值,说明还未写入,用true作为默认值
isFirstIn = preferences.getBoolean("isFirstIn", true);// 判断程序第几次运行,如果是第一次运行则跳转到引导界面,否则跳转到主界面
if (!isFirstIn) {
mHandler.sendEmptyMessageDelayed(GO_HOME, delayTime);} else {
// 使用Handler的postDelayed方法,3秒后执行GuideActivity
mHandler.sendEmptyMessageDelayed(GO_GUIDE, delayTime);editor.putBoolean("isFirstIn", false);editor.commit();}}private void goHome() {Intent intent = new Intent(this, StartActivity.class);startActivity(intent);this.finish();
}private void goGuide() {Intent intent = new Intent(this, GuideActivity.class);startActivity(intent);this.finish();
}}
标签:android style class c tar ext
原文地址:http://www.cnblogs.com/hxsyl/p/3724020.html