package text.xujiajian.asus.com.shaopdemo; import android.content.SharedPreferences; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences sp =this.getSharedPreferences("name",MODE_PRIVATE); boolean isFirst =sp.getBoolean("isFirst",true); SharedPreferences.Editor editor=sp.edit(); if(isFirst){ Log.i("", "onCreate: 第一次"); editor.putBoolean("isFirst",false); editor.commit(); }else { Log.i("", "onCreate: 第二次"); } } }
判断是否第一次登录
最新推荐文章于 2023-04-13 09:50:47 发布