gpt4 book ai didi

android - 如何只显示一次登录然后在android中直接启动应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:30:38 25 4
gpt4 key购买 nike

我在只进行一次登录时遇到了麻烦...我的目标是第一个用户获得登录屏幕..如果他是新用户,他将注册然后登录...从那时起,当用户启动应用程序时,他应该直接重定向到跳过登录页面的主要 Activity ..请 friend 帮我解决这个问题..请给我任何教程或任何代码...请告诉我如何在 list 文件中修改...

我在登录 Activity 中使用了这样的方法,但我没有完成我的任务。

SharedPreferences pref;
SharedPreferences.Editor editor;
pref = getSharedPreferences("testapp", MODE_PRIVATE);
editor = pref.edit();
editor.putString("register","true");
editor.commit();
String getStatus=pref.getString("register", "nil");
if(getStatus.equals("true"))
// redirect to next activity
else
// show registration page again

最佳答案

以这种方式实现您的SharedPreferences:

Boolean isFirstTime;

SharedPreferences app_preferences = PreferenceManager
.getDefaultSharedPreferences(Splash.this);

SharedPreferences.Editor editor = app_preferences.edit();

isFirstTime = app_preferences.getBoolean("isFirstTime", true);

if (isFirstTime) {

//implement your first time logic
editor.putBoolean("isFirstTime", false);
editor.commit();

}else{
//app open directly
}

关于android - 如何只显示一次登录然后在android中直接启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21980324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com