简体   繁体   中英

First Screen. Shown on first Launch, ONLY

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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