APP中的OneTime SetUp注册屏幕?

时间:2013-12-27 13:41:26

标签: android android-intent android-fragments

嗨我想在我的应用程序中实现用户必须注册一次,当他再次打开应用程序时,他应该直接去欢迎活动而无需注册活动。所以如何实现这一点。

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
}

我试过这个 感谢

2 个答案:

答案 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)

以下是步骤:

  • 在您的设置/注册屏幕中,点击注册按钮并完成工作后,使用常量键将操作结果保存在共享首选项中。
  • 创建一个启动活动,将其作为您的初始活动。
  • 在splash活动的onResume方法中,检查相关键的值。
    • 如果已注册,则触发主要活动
    • 其他显示设置/注册活动