嗨我想在我的应用程序中实现用户必须注册一次,当他再次打开应用程序时,他应该直接去欢迎活动而无需注册活动。所以如何实现这一点。
savedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
if(savedPreferences.getBoolean(PREF_SHOW_ABOUT_ON_APP_START, true)){
Intent intent = new Intent(this, SetupActivity.class);
startActivity(intent);
savedPreferences.edit().putBoolean(PREF_SHOW_ABOUT_ON_APP_START, false).commit(); // YOu could do this line within the SetupActivity to ensure they have actually done what you wanted
finish();
} else {
// Go somewere else
}
我试过这个 感谢
答案 0 :(得分:0)
创建两个活动XML文件。一个用于注册,另一个用于App。但是你应该只有一个活动类。在类onCreate()函数中检查用户已经重新注册的首选项。如果已注册,则显示主应用程序XML文件(如果未显示注册XML
)<强>编辑:强>
SharedPreferences preference = getSharedPreferences("PREFERENCE", MODE_PRIVATE);
boolean status = preference.getBoolean("registration_completed", false);
if (status){
setContentView(R.layout.registration_form);
}else{
setContentView(R.layout.main_app);
}
答案 1 :(得分:0)
以下是步骤: