How to replace the Chromecast Notification icon using Cast SDK v3

I recently implemented Chromecast in an android project and decided to go with the new Cast SDK v3. Implementation is pretty straight forward and there is good documentation to get you up and running with basic functionality. However, there are some smaller areas where the docs are lacking. One of these areas is customizing the notification icon while cast is running in the background.

This is a requirement in Google’s Cast Checklist:

Seems like a simple requirement that helps app branding. https://developers.google.com/cast/docs/design_checklist/sender#sender-control-notification

Not a big deal. Just need an asset and somewhere to put it. I’ll leave the asset up to you and the documentation should tell us where to put it. But wait, why am I writing this then? Because the documentation is not very straight forward on how to do this. With a little digging you would probably end up in the NotificationOptions reference. Here you would learn about a method called getSmallIconDrawableResId().

https://developers.google.com/android/reference/com/google/android/gms/cast/framework/media/NotificationOptions#getSmallIconDrawableResId()

Nice! Now we can override ic_notification_small_icon.xml in our drawable resource folder and we will be all set.

If you override this you will NOT see a result.

This is almost the name of the asset we need to override and the motivation behind this post. The actual asset that needs to be overridden is cast_ic_notification_small_icon.xml Overriding this with your asset will give you the desired results. Below is an example of this file

Happy casting!