ulas
ulas

Reputation: 93

How to understand first install in Android Apps?

I need to make a greeting message when the user installed and run apps for the first time. What's the simple way to get the app is running for the first time?

Upvotes: 0

Views: 130

Answers (2)

Ken Wolf
Ken Wolf

Reputation: 23279

Use SharedPreferences to store a flag of whether you need to show the message or not.

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean showMsg = prefs.getBoolean("show_msg", true);
if (showMsg) {
    // show the message
    // then save the flag
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean("show_msg", false);
    editor.commit();
}

Put this in onCreate() or similar.

Next time the snippet is run the value will be false so the message will not be shown.

Upvotes: 1

Tasos Moustakas
Tasos Moustakas

Reputation: 408

Try inserting Toast objects. See documentation.

Upvotes: 0

Related Questions