zoukankan      html  css  js  c++  java
  • 判断用户是否是第一次打开该app

    package com.example.fujilun_2;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.content.SharedPreferences;
    import android.os.Bundle;
    
    public class LaunchActivity extends Activity{
        //要保存的文件名
        private final String SHARE_APP_TAG= "firstOpen";
        private Boolean first;
        private SharedPreferences setting;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            
            setContentView(R.layout.activity_launch);
            
            setting = getSharedPreferences(SHARE_APP_TAG, 0);  
            first = setting.getBoolean("FIRST",true); 
            
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    
                    if(first){
                        setting.edit().putBoolean("FIRST", false).commit();  
                        Intent intent=new Intent(LaunchActivity.this,DemoActivity.class);
                        startActivity(intent);
                        finish();
                    }else{
                        Intent intent=new Intent(LaunchActivity.this,LoginActivity.class);
                        startActivity(intent);
                        finish();
                    }
                    
                }
            }).start();
    
            
        }
    }
  • 相关阅读:
    网络编程
    并发编程-线程池
    并发编程-集合
    并发编程-AQS
    并发编程-CAS
    并发编程-volatile和synchronized的区别
    并发编程-synchronized
    并发编程-java内存模型
    JVM-分代垃圾回收器
    性能优化
  • 原文地址:https://www.cnblogs.com/qq1272850043/p/6202526.html
Copyright © 2011-2022 走看看