I want to remove notifications from another application shown in the notification bar. Is that possible? NotificationManager.cancelAll();
cancels only notificat
You can close any notification use NotificationListenerService:
public class NotificationListener extends NotificationListenerService {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
cancelNotification(sbn.getKey());
}
}
Your application must have BIND_NOTIFICATION_LISTENER_SERVICE permission. https://developer.android.com/reference/android/service/notification/NotificationListenerService.html
You can cancel your own notifications using NotificationManager.
But you can't cancel other apps' notifications, that is not possible.
From Android 4.3 onward, you can now cancel notifications from any apps.
You need to register your app as NotificationListenerService, then call NotificationListenerService.cancelNotification(String pkg, String tag, int id)
to cancel one notification.