- 将做登记活动将只显示一次
- 注册之后,控制应该移动到 下一个主要活动
我用下面的代码
以下代码不符合我的要求?
任何帮助将不胜感激!
在注册活动代码
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor=prefs.edit();
editor.putBoolean("registration", true);
editor.commit();
守则主要活动
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean regComplete =prefs.getBoolean("registration", false);
SharedPreferences.Editor editor =prefs.edit();
editor.putBoolean("registration", false);
editor.commit();
if(regComplete)
{
startActivity(new Intent(this, SecureXActivity.class));
} else
{
startActivity(new Intent(this, LoginActivity.class));
}
也'SecureXActivity.class'是你的**主要发射活动** ... – user370305 2012-07-26 13:21:18
这应该有效。主要问题(在OP的原始代码中)是在Main Activity中,程序开始的地方(每次运行),注册设置为false。每一次。这样,每次程序重新运行时,用户都必须注册。 – Jochem 2012-07-26 13:21:49
@Jochem - 在OP的代码。如果注册没有完成,OP将启动一个'LoginActivity',注册代码在'RegistrationActivity'中。 – user370305 2012-07-26 13:37:12