1

I know I could have animated download icon in status bar when downloading a file by using the default android resource android.R.drawable.stat_sys_download. My question is how to have this animated icon in the contentView of download notification? Like when you are downloading a file with Chrome.

animated icon in notification contentView

I attempted to display the resourse using ImageView but it does not support animated icons and the icon was displayed like an ordinary icon with no animations.

RaSha
  • 1,356
  • 1
  • 16
  • 30
  • 1
    visit this link: https://stackoverflow.com/questions/34037962/how-to-animate-the-progress-notification-icon – Masoud Mokhtari Jun 01 '19 at 18:41
  • but I want animated icon to be displayed in content view of the notification. I already have the resource in the status bar as I said. Thank you anyway :) – RaSha Jun 02 '19 at 04:17

1 Answers1

0

I found the solution. You should use notification styling. Icon is one of the major components in the notification which android sets its style. So in addition to use android.R.drawable.stat_sys_download as icon resource, you should use .setStyle even if you have custom notification layout.

    mBuilder = new NotificationCompat.Builder(context, channelID)
            .setCustomContentView(collapsedView)
            .setColor(context.getResources().getColor(R.color.colorPrimary))
            .setSmallIcon(android.R.drawable.stat_sys_download)
            .setOngoing(true)
            .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setPriority(NotificationCompat.PRIORITY_LOW);
RaSha
  • 1,356
  • 1
  • 16
  • 30