码迷,mamicode.com
首页 > 其他好文 > 详细

WelcomeActivity

时间:2015-01-07 18:13:39      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

package nl.lance.dribbb.activites.welcome;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import nl.lance.dribbb.R;

import nl.lance.dribbb.activites.ContentActivity;

public class WelcomeActivity extends Activity {
	
  private static final int GO_HOME = 100;
  private static final int GO_GUIDE = 200;
  boolean isFirst = false;
  private Handler mHandler = new Handler() {
  @Override
  public void handleMessage(Message msg) {
    switch (msg.what) {
	    case GO_HOME:
	      goHome();
		    break;
	    case GO_GUIDE:
	      goGuide();
		    break;
	    }
    }
  };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_welcome);
		init();
	}

	private void init() {
		SharedPreferences preferences = getSharedPreferences("first_pref", MODE_PRIVATE);
		isFirst = preferences.getBoolean("isFirst", true);
		if(!isFirst) {
			mHandler.sendEmptyMessageDelayed(GO_HOME, 150);
		} else {
			mHandler.sendEmptyMessageDelayed(GO_GUIDE, 150);
		}
	}
	
	private void goHome() {
		Intent intent = new Intent(WelcomeActivity.this, ContentActivity.class);
		startActivity(intent);
		overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
		this.finish();
	}
	
	 private void goGuide() {
	    Intent intent = new Intent(WelcomeActivity.this, GuideActivity.class);
	    startActivity(intent);
	    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
	    this.finish();
	  }
}

  

WelcomeActivity

标签:

原文地址:http://www.cnblogs.com/nongzha/p/4208720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!