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?