Reputation: 240
I tried using below code which adds only one image in the notification bar and sets smallIcon image in status bar
notification.setSmallIcon(R.drawable.badge); //foreground png image
notification.setColor(getResources().getColor(R.color.ic_launcher_background)); // background png image(red)
Please refer the above image, i would like to know how to set the second image in the notifications.
Upvotes: 1
Views: 281
Reputation: 21043
setLargeIcon(Bitmap bitmap)
by definition accept Bitmap
or an overloaded implementation setLargeIcon (Icon icon)
accept instance of Icon
.
Notification.Builder setLargeIcon (Bitmap b)
Set large icon as follows.
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
R.mipmap.ic_launcher))
.setContentTitle("Title")
.setContentText("Hi")
.setAutoCancel(true)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0 , notificationBuilder.build());
For App tagetting Android O . NotificationCompat.Builder(Context context)
has been deprecated. You have to use the constructor which has the channelId parameter see Documentation:
NotificationCompat.Builder(Context context, String channelId)
Upvotes: 3