SharedPreferences
をお試しください。 ActivityA
のon createでは、SharedPreferencesにユーザーがサインアップしているかどうかを判断する特定の値が含まれているかどうかを確認します。それが設定されていないか、それが必要な値を持っていない場合は、ActivityB
にユーザーをリダイレクトするか、他ActivityC
コード:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences pref = this.getSharedPreferences("my_prefs", Context.MODE_PRIVATE);
if(pref.contains("MY_KEY") && pref.getBoolean("MY_KEY", false)){ //first stratup or user has not signed in yet
Intent intent = new Intent(this, ActivityC.class);
startActivity(intent);
} else { //already signed up
Intent intent = new Intent(this, ActivityB.class);
startActivity(intent);
}
setContentView(R.layout.activity_main);
}
いけないユーザーがサインアップした後SharedPreferences
内/挿入値を保存することを忘れ。
コード:
SharedPreferences pref = this.getSharedPreferences("my_prefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
if(sign_up_success){
editor.putBoolean("MY_KEY", true);
editor.commit();
}
あなたの活動の好みをご利用ください。プリファレンスが設定されている場合、他のアクティビティにリダイレクトしようとします – Shriram
sharedpreferenceを使用してユーザーアクティビティを保存します.. – Andolasoft
[link](http://stackoverflow.com/questions/30664868/one-time-sign-in/)の重複している可能性があります30665342#30665342) –