开发者

Showing Terms and Conditions for first time in an android app

开发者 https://www.devze.com 2023-03-01 16:59 出处:网络
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 ha开发者_JAVA百科ve to show the terms and conditio

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 ha开发者_JAVA百科ve 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?


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();
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消