Reputation: 99
I need to show a lot of notifications to StatusBar. But in order to not to fill up statusbar with my messages I have to automatically remove notification after 1 minute, for example. How can I do this?
Upvotes: 0
Views: 267
Reputation: 99
I did it with Timer:
Notification notification = nb.build();
notifManager.notify(id, notification);
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
notifManager.cancel(id);
timer.cancel();
}
}, REMOVE_TIME, 1000);
Upvotes: 0
Reputation: 6941
Follow these steps
notification
and create Alarm
for required durationNotificationManager.cancel(id)
in BroadcastRecevier
of Alarm
Upvotes: 1