android开发之splash闪屏页判断是否第一次进入app代码

package com.david.david.zhankudemo.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.widget.ImageView;

import com.david.david.zhankudemo.Constant.SPManager;
import com.david.david.zhankudemo.R;
/**
 * 作者:David on 2016/3/14 14:47
 * <p/>
 * 联系QQ:986945193
 * <p/>
 * 微博:http://weibo.com/mcxiaobing
 */
public class SplashActivity extends Activity {

    private ImageView iv_splash;

    private Context mContext;

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (SPManager.IS_FIRST_START_APP) {
                Intent intent = new Intent(mContext, GuideActivity.class);
                SPManager.IS_FIRST_START_APP = false;
                startActivity(intent);
                finish();
            } else {
                Intent intentMain = new Intent();
                intentMain.setClass(getApplicationContext(), MainActivity.class);
                mContext.startActivity(intentMain);
                finish();

            }

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_splash);
        mContext = this;
        iv_splash = (ImageView) findViewById(R.id.iv_splash);


//        new CreatShortCutUtils(SplashActivity.this).addShortcut();
//        AlphaAnimation start = new AlphaAnimation(0.0f, 0.1f);
//        start.setDuration(1000);
//        iv_splash.startAnimation(start);

        loadSplashImage();
    }

    private void loadSplashImage() {
        mHandler.sendEmptyMessageDelayed(1, 2000);


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeMessages(1);
    }
}

程序员小冰博客:http://blog.csdn.net/qq_21376985 技术交流QQ986945193 微博:http://weibo.com/mcxiaobing
原文地址:https://www.cnblogs.com/mcxiaobing/p/5472109.html