0

I have a simple query , whose answer i do not seem to get from anywhere. I have a notification like below

    NotificationCompat.Builder mBuilder= new NotificationCompat.Builder(baseContext).setLargeIcon(large_icon)
                .setSmallIcon(R.drawable.message_received_small_icon)
                .setContentIntent(pendingIntent)
                .setAutoCancel(true)
                .setSound(soundUri);
mBuilder.setContentText(_summaryText);

        notification = mBuilder.build();

I know setContentText will set message say M, the user want to show on the notification. My question is is there any way i can show an icon with the message M. I want to show an icon to left of message . Is that possible with default notification. I have been stuck at it for a long time.

I can create a custom remoteview for displaying the icon . But As android versions are updating , each version has a different style of notification . So if i use custom layout for notification , then i will need to create custom view for all android versions, which i want as a last option.

Please help if it is possible with currently available styles.

Pardeep Kr
  • 479
  • 2
  • 6
  • 25

2 Answers2

0

in your notification builder set large icon will set the icon in left of your notification message.

  mBuilder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
                    R.mipmap.ic_launcher))
Anjali
  • 1
  • 1
  • 13
  • 20
  • I am not talking about the large icon. I think you misunderstood the question . Basically i want to show an icon where setContentText is shown. – Pardeep Kr Dec 28 '16 at 06:41
0

To display larger images/icons, you need to set custom remote view and customize your layout.xml.

To add small Emoji icons you can just add icon's Unicode into string.
To find Emoji icons go to here: https://emojipedia.org/google/

Example:

NotificationCompat.Builder(context, channelId)
        .setContentTitle("Your Title")
        .setContentText("\uD83D\uDCC4  -> This is Page Facing Up emoji icon")
Mitul Varmora
  • 3,832
  • 1
  • 12
  • 21