Reputation: 2063
I have a background service running to get data. I check for new data and send status bar notification. Sending notification is part of the service. When user sees that notification, he logs on to the application and accepts it. That time I want to delete it from status bar. Can I do that ?
Upvotes: 7
Views: 13935
Reputation: 3201
if (Context.NOTIFICATION_SERVICE!=null) {
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager nMgr = (NotificationManager) getApplicationContext().getSystemService(ns);
nMgr.cancel(0);
}
write the above code in the second class and create the notifications in the first class using the id 0.
Upvotes: 18