Reputation: 21929
Hi I don't want to display the any notification service in status bar if i saw one notification service once .For example i am displaying persons who are exceeding the 20 km distance from my location .some persons are displayed.when i saw it once then automatically the icon in the status bar is don't displayed.For this one give me some suggestions .Thanks in advance.
Upvotes: 3
Views: 450
Reputation: 93143
I do this:
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
boolean used = sp.getBoolean("notif_used", false);
if ( used )
return;
else {
/* show the notification */
Editor editor = getSharedPreferences().edit();
editor.putBoolean("notif_used", true);
editor.commit();
}
Upvotes: 1
Reputation: 29745
If your question is about preventing the display of notifications once the user clears one of your previous notifications, you'll probably need to maintain your own data structure to monitor this.
The idea is:
You might also want to look into Notification.deleteIntent
.
Caution: Before doing this, consider if this is really necessary. It might be sufficient to simply collapse visible notifications by reusing notification IDs.
Upvotes: 1