2

Ive made a custom notification using RemoteView - does anyone know how to set the icon in that using a bitmap? or a drawable thats not in a package - or at least show how to add a package/resource or update it so it can be set.

Im targeting minimum API of 17 , so Icon.CreateWithBitmap is sadly not an option for me since the min API there is 23.

Nevaran
  • 137
  • 9

1 Answers1

5

You could use SetLargeIcon() to change the icon to your bitmap. The SetLargeIcon() requires a Bitmap instance.

For example:

builder.SetLargeIcon(bitmap);

The official document: notifications

The SetSmallIcon() needs a A resource ID in the application's package of the drawable to use. You could just copy your icons and paste them into drawable folder. And set the Build Action to AndroidResource in Properties

For example:

builder.SetSmallIcon(Resource.Drawable.YOUR_ICON);

If you want to set bitmap as ImageView background, please try SetImageBitmap():

imageview.SetImageBitmap(bitmap);

Or

 imageview.SetImageBitmap(BitmapFactory.DecodeResource(Resources, Resource.Drawable.YOUR_ICON )); 

You could also refer to this answer.

Billy Liu - MSFT
  • 2,168
  • 1
  • 8
  • 15
  • That is useless for me- i need it to show a string thats been generated in the status bar(top of the device) – Nevaran Dec 26 '17 at 09:46