• 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
  • 相关阅读:
    bzoj 2213: [Poi2011]Difference
    51nod 1079 中国剩余定理
    51nod 1074 约瑟夫环 V2
    SpringBoot:第二篇 集成mybatis
    SpringBoot:第二篇 集成日志lombok
    SpringBoot:第一篇 新建spring boot 应用
    JVM常用内存参数配置
    深入研究Java GC
    应用性能监控分析
    Java -- 深入浅出GC自动回收机制
  • 原文地址:https://www.cnblogs.com/mcxiaobing/p/5472109.html
Copyright © 2020-2023  润新知