简体   繁体   English

检查我的应用程序的第一次用户是否在Android中

[英]Check if first-time user of my App in Android

In my App, first it shows a splash screen. 在我的应用程序中,首先它显示了一个启动画面。 After that another activity, then my main activity must be shown. 在那另一个活动之后,必须显示我的主要活动。 This is my design plan. 这是我的设计方案。 The second activity (ie before main activity) must be shown for the first-time user of the app. 必须为应用的首次使用者显示第二个活动(即主活动之前)。 If he/she closes the app, splash screen will redirect to main activity automatically. 如果他/她关闭应用程序,启动屏幕将自动重定向到主要活动。 How do I do this? 我该怎么做呢? Any ideas? 有任何想法吗? I am developing my app for Android phones. 我正在为Android手机开发我的应用程序。

You can eg use a sharedPreference-object to store a boolean value that tells you if this is the first time the user opens the application. 例如,您可以使用sharedPreference-object来存储一个布尔值,该值告诉您这是否是用户第一次打开应用程序。 Check the preference when the user starts the application, and if it returns true then show the middle screen. 用户启动应用程序时检查首选项,如果返回true,则显示中间屏幕。

private SharedPreferences mPreferences;
....
boolean firstTime = mPreferences.getBoolean("firstTime", true);
if (firstTime) { 
    SharedPreferences.Editor editor = mPreferences.edit();
    editor.putBoolean("firstTime", false);
    editor.commit();
    showMiddleActivity();
}

Something like that. 这样的事情。

Edit: Beaten to it by jqpubliq... 编辑:jqpubliq击败它...

Persist a flag in preferences and check it on startup. 首选项中保留一个标志并在启动时检查它。 Change it's state after the splash is shown once. 在一次显示启动后更改它的状态。

You'd need to save data somewhere, in your case it might be easiest to just write out an empty file after the first run of the app. 你需要在某个地方保存数据,在你的情况下,在第一次运行应用程序后写出一个空文件可能是最容易的。 So you would check for the existence of this file and if it was there then you wouldn't show the second activity, and would just show the main activity. 因此,您将检查此文件是否存在,如果它存在,那么您将不会显示第二个活动,并且只显示主要活动。

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

相关问题 如何检查这是否是用户第一次使用我的应用程序 - How to check if it is the first time a user has used my app 如何查看用户第一次登录的时间 Android Studio SQLite - How to check when the user logins for the first time Android Studio SQLite 检查用户是否首次使用Firebase身份验证和数据库登录Android应用 - Check if is user first login on Android App using Firebase Auth and Database 使用 Servlet 中的 COOKIES 检查用户是否第一次访问 - To check if user first time visit or not with COOKIES in Servlet Java Swing图形-为什么第一次渲染不能按预期工作? - Java Swing Graphics - Why does the first-time rendering not work as expected? 在java app中检测第一次用户 - Detect first time user in java app android gps应用程序仅在第一次工作 - android gps app just working first time 首次在 android 应用程序中显示条款和条件 - Showing Terms and Conditions for first time in an android app 如何检查用户是否刚刚在 firebase 中首次登录 Google - How to check if A user just Google signed in for first time in firebase Android Studio:“我的第一个应用程序”不起作用 - Android Studio: “My First App” does not work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM