How to use Glide in remoteViews?

后端 未结 1 899
盖世英雄少女心
盖世英雄少女心 2021-02-13 20:19

I\'m using Glide for all loading images from server, but I\'m having troubleshooting trying to set them in a correct way to notifications and RemoteControlClientCompat (that coo

相关标签:
1条回答
  • 2021-02-13 21:08

    You need to set use NotificationTarget class to set your notification image as glide target

    NotificationTarget notificationTarget = new NotificationTarget(  
        context,
        remoteView,
        R.id.iv_album_art,
        notification,
        NOTIFICATION_ID);
    

    and then use that target in usual glide way

        Uri uri = ContentUris.withAppendedId(PlayerConstants.sArtworkUri,
            mediaitem.getAlbumId());
    
        Glide.with(getApplicationContext()) 
        .load(uri)
        .asBitmap()
        .into( notificationTarget );
    

    It is explained in Glide's guideline here

    https://futurestud.io/blog/glide-loading-images-into-notifications-and-appwidgets

    You might also like to animate album art change- Its described here:-

    https://futurestud.io/blog/glide-custom-animations-with-animate

    0 讨论(0)
提交回复
热议问题