简体   繁体   English

首次在 android 应用程序中显示条款和条件

[英]Showing Terms and Conditions for first time in an android app

I am developing an android app in which the first screen is the splash screen.我正在开发一个 android 应用程序,其中第一个屏幕是启动屏幕。 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?有没有API呢?

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 ).您可以使用SharedPreferences教程)。

Just check for a certain value onCreate().只需检查某个值 onCreate()。 If it's not there, do something, then set the value.如果它不存在,做一些事情,然后设置值。 Next time, the value will be there and you can skip it.下一次,该值将在那里,您可以跳过它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM