Showing Terms and Conditions for first time in an android app

让人想犯罪 __ 提交于 2019-12-12 01:52:16

问题


I am developing an android app in which the first screen is the splash screen. If the user is a first time user(meaning the app was just installed) I have to show the terms and conditions otherwise, I have to show the login screen.

How to get the number of times the application was opened or an indication that the app is opened for the first time? Is there any API for it?


回答1:


You don't need to have this counter:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if(!prefs.getBoolean(KEY_EULA_ACCEPTED, false)) {
    showEula();
    // Determine if EULA was accepted this time
    prefs.edit().putBoolean(KEY_EULA_ACCEPTED, true).commit();
}



回答2:


You could use SharedPreferences (tutorial).

Just check for a certain value onCreate(). If it's not there, do something, then set the value. Next time, the value will be there and you can skip it.



来源:https://stackoverflow.com/questions/5849076/showing-terms-and-conditions-for-first-time-in-an-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!