第一个屏幕。显示在第一次发射,ONLY [英] First Screen. Shown on first Launch, ONLY

查看:78
本文介绍了第一个屏幕。显示在第一次发射,ONLY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当用户安装我的应用程序并启动它的第一次尝试areshown的应用程序的功能,但随后该屏幕可以由用户neverbe访问。它不应该在同一设备上再次显示,直到永远。这就像,显示第一次启动一个初始画面并在后续推出无初始画面。任何想法或例子来那怎么做。

I want that when the users install my application and launch it for the first time try areshown " features of the application " but then that screen can neverbe accessed by the user. It should never display again on the same device,ever. It's just like, Showing an Initial Screen on first launch and no initial screen on subsequent launches. Any idea or example as to how can that be done.

推荐答案

使用共享preferences 来设置一个标志。定义键,在的onCreate(),检查它的设置与否。如果不是,显示该窗口并编写关键preferences。

Use SharedPreferences to set a flag. Define a key, and in your onCreate(), check if it's set or not. If it's not, display the window and write the key to preferences.

private static final String FIRST_LAUNCH = "first_launch";

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences();

//Assume true if the key does not yet exist
if (prefs.getBoolean(FIRST_LAUNCH, true)) {
    //Display window
} else {
    SharedPreferences.Editor edit = prefs.edit();
    edit.putBoolean(FIRST_LAUNCH, false);
    edit.commit();
}

这篇关于第一个屏幕。显示在第一次发射,ONLY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆