How to load Glide cached image in NotificationCompat.Builder.setLargeIcon()?

前端 未结 1 1554
情深已故
情深已故 2021-01-19 03:11

Like this image I am trying to set notification large icon as user profile thumbnail like whatsapp or other chatting apps

I have tried

 Glide.with(         


        
1条回答
  •  执笔经年
    2021-01-19 03:44

    If you set the large icon using glide..the you should also notify the NotificationManager onResourceReady(resource, transition)

    .into(new SimpleTarget() {
        @Override
        public void onResourceReady(Bitmap res, Transition t) {
           builder.setLargeIcon(res);
           yourNotificationManager.notify(id, builder.build());
    
        }
    });
    

    This is because glide uses background thread to load image..so before your image is loaded into builder... the notification manager is already notified (mainthread) with builder not having large image..

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