Search code examples
androidnotificationsstatusbarremoteview

How to get all notification of all application have custom notification running


I'm a beginner. I have a problem about custom notification. I want to read all information of normal notification and custom notification use RemoteView. Example I want get all information about notification music(art cover, song, next, pause, back action) I search very very much, but can't find the document I need. If you know, please tell me. Thank so much!


Solution

  • What you're looking for is a NotificationListenerService. From the docs:

    A service that receives calls from the system when new notifications are posted or removed, or their ranking changed.

    If you're specifically looking for ways to read Metadata and the music app is using a MediaSessionCompat, you can use MediaControllerCompat.getMetadata() to read the data off of the notification.

    To display the actual content of the notification in your app, what you can do is get one of the many RemoteViews from the Notification object you received, then use this answer to display your notification.