简体   繁体   English

仅在首次启动时如何具有启动屏幕?

[英]How to have splash screen at first launch only?

I have a splash activity in my app that launches and then loads the main class after 5 seconds. 我的应用程序中有一个启动活动,它会启动,然后在5秒钟后加载主类。 I'm thinking of changing it to where the splash only displays on the initial launch of the app. 我正在考虑将其更改为仅在应用程序的初始启动时显示启动的位置。 I was thinking of just writing a text file to the filesystem and then checking to see if its there. 我正在考虑只是将文本文件写入文件系统,然后检查其是否存在。 If its found, then dont load the splash screen. 如果找到它,则不要加载初始屏幕。 Is there a better way of doing a check to see if the app is on the first launch? 有没有更好的方法来检查该应用程序是否首次启动?

Instead of that you can use SharedPreferences because its easy to implement, fetch and take values from it as compared to file system. 取而代之的是,您可以使用SharedPreferences,因为与文件系统相比,它易于实现,获取并从中获取值。

Refer this question for the example of SharedPreference: Android-sharedpreference 请参阅此问题以获取SharedPreference的示例: Android-sharedpreference

您可以使用SharedPreference保存代表初始屏幕的简单字符串。

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

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