package com.baozilichao.superone.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import com.baozilichao.superone.R;
import com.baozilichao.superone.Utils.CommenUtis;
public class Splash_lead extends Activity {
SharedPreferences sharedpreferences;
boolean isFirstIn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.item0);
initView();
initFive();
}
private void initView() {
sharedpreferences = getSharedPreferences(CommenUtis.CONTAIN, MODE_PRIVATE);
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
isFirstIn = sharedpreferences.getBoolean("isFirstIn", true);
//如果是首次登陆,跳转到引导页,首次登陆改为false
if (isFirstIn) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean("isFirstIn", false);
editor.commit();
Intent intent = new Intent( Splash_lead.this,MainActivity.class);
startActivity(intent);
finish();
//如果不是首次登陆,跳转到主页
} else {
Intent intent = new Intent( Splash_lead.this, First_Join.class);
startActivity(intent);
finish();
}
}
};
//传消息给主线程,要求显示两秒
private void initFive() {
new Thread(new Runnable() {
@Override
public void run() {
handler.sendEmptyMessageDelayed(0, 2000);
}
}).start();
}
}
首次进入App
最新推荐文章于 2021-12-02 20:10:29 发布