Reputation: 131
I am launching a paid version of my app. I want to notify the current users of the paid version being available now. How do I give a one time notification to the users about it. The only constraint is that this alert/notification should be launched only once. In C, I would have done it using static variable. Here should I do it onCreate? But if app is killed by the OS, the next time app starts onCreate would be called and that would result in the same notification again.
Upvotes: 1
Views: 81
Reputation: 4567
You need to use SharedPreferences, see following code:
@Override
protected void onCreate(Bundle savedInstanceState) {
...
SharedPreferences prefs = PreferenceManager.getDefaultPreferences(this);
if(prefs.getBoolean("not_notified", true))
{
//display alert
prefs.edit().putBoolean("not_notified", false).commit();
}
Upvotes: 0
Reputation: 61
maybe u can save the variable in SharedPrefrence. http://developer.android.com/guide/topics/data/data-storage.html#pref
Upvotes: 2