答案 0 :(得分:0)
为此使用SharedPreferences类。
实施例。创建SharedPreferences类。
公共类SharedPreferencesUtility {
SharedPreferences sharedpref;
public SharedPreferencesUtility(Context context) {
sharedpref = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
}
public void setVerifiy(boolean b) {
sharedpref.edit().putBoolean("isVerify", b).commit();
}
public boolean getVerifiy() {
return sharedpref.getBoolean("isVerify", false);
}
}
使用 setVerifiy 方法,当您通过Facebook登录并在splash /中检查方法 getVerifiy 之后其他活动oncreate方法。
private Activity activity;
private SharedPreferencesUtility preferencesUtility;
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_splash);
activity = SplashActivity.this;
preferencesUtility = new SharedPreferencesUtility(activity);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (preferencesUtility.getVerifiy()) {
startActivity(new Intent(getApplicationContext(), HomePage.class));
finish();
} else {
startActivity(new Intent(getApplicationContext(), LoginPage.class));
finish();
}
}
}, 3000);
}