How to use Glide in remoteViews?

守給你的承諾、 提交于 2019-12-03 12:01:40

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!