如何使活动只有一次启动时,应用程序启动的第一次? [英] How to make Activity to start only once when the app is started for the first time?
问题描述
我有一个注册的活动,我想,当应用程序被启动第一次只启动一次。如果登录后,当应用程序启动时我想直接去第二个活动是第二次 - FirstWindow
感谢你在前进!
在活动开始的第一次:保存真正的价值
共享$ P $粉煤,每次应用程序启动检查共享$ P $如果PF
真正转到下一个活动否则显示第一个活动(UR注册
页)
块引用>1.Declare变量
共享preferences preF;
共享preferences.Editor编辑;2.in onCrete方法
preF = getShared preferences(testapp,MODE_PRIVATE);
编辑= pref.edit();3,当用户成功注册(点击注册按钮)
editor.putString(注册,真);
editor.commit();然后每次ü可以检查:
的getStatus字符串= pref.getString(注册,无);
如果(getStatus.equals(真))
重定向到下一个活动
其他
再次显示注册页面I have a Registration Activity, which I want to be started only once when the app is started for the first time. If the registration is made, the second time when the app is started I want to go directly to the second Activity - FirstWindow.
Thank you in advance!
解决方案when the activity is started for the first time : save true value in shared pref and everytime the app launches check the shared pref if true go to next activity else show first activity (ur registration page)
1.Declare variables
SharedPreferences pref; SharedPreferences.Editor editor;
2.in onCrete method
pref = getSharedPreferences("testapp", MODE_PRIVATE); editor = pref.edit();
3.When user successfully registers (click on register button)
editor.putString("register","true"); editor.commit();
Then every time u can check by :
String getStatus=pref.getString("register", "nil"); if(getStatus.equals("true")) redirect to next activity else show registration page again
这篇关于如何使活动只有一次启动时,应用程序启动的第一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!