1.登陆页面
SharedPreferences sp = getSharedPreferences("Login", MODE_PRIVATE); SharedPreferences.Editor edit = sp.edit(); edit.putBoolean("isLogin", true); edit.putString("U_Tel", Contast.user.getU_Tel()); edit.putString("U_IMEI", Contast.user.getU_IMEI()); edit.commit();
2.判断页面
private void startLogin() { Intent intent = new Intent(MainActivity.this, LoginActivity.class); startActivity(intent); } private boolean checkLogin() { SharedPreferences sp = getSharedPreferences("Login", MODE_PRIVATE); boolean isLogin = sp.getBoolean("isLogin", false); return isLogin; }
if (checkLogin()) { //TODO //如果已经登录,则查看帮助详情 } else { //如果没有登录,直接跳转登录界面 startLogin(); }