1

I created a service to listen to the notification bar and view to grab the music media information in the notification bar.

like this:

public override void OnNotificationPosted(StatusBarNotification sbn)
{
    string packageName = sbn.PackageName;

    if (!packageName.Contains("clash")) 
    {
        if (packageName.Contains("music"))
        {
            var info = sbn.Notification.Extras;
            //var largeIcon = sbn.Notification.LargeIcon;
            var title = info.Get("android.title")?.ToString();
            var singer = info.Get("android.text")?.ToString();
            //var subText = info.Get("android.subText")?.ToString();

            Intent intent = new Intent(AppWidgetConstants.UpdateMusicInfo);
            intent.PutExtra("music_title", title);
            intent.PutExtra("music_singer", singer);

            //intent.PutExtra("music_album", largeIcon);
           
            XApp.Application.Context.SendBroadcast(intent);

        }
    } 
    base.OnNotificationPosted(sbn);
}

I can get the music title and singer information in the code, but I can't get the album cover

I tried to use largeIcon to get it, but it is "null" and has been marked as obsolete

I've also tried GetLargeIcon(), and I can't get it this way.

Can someone tell me what to do?

Jeff
  • 11
  • 2
  • I've seen your question. You may define a method to get the image Id passed from the notification bar. For details, please refer to the URL:“https://stackoverflow.com/questions/32859260/how-to-get-notification-icon-of-other-app“ and "https://stackoverflow.com/questions/18044044/notificationlistenerservice-get-notification-icon". – Hongxin Sui-MSFT Aug 26 '22 at 07:21

0 Answers0