3

I'm trying to display an emoji on notification bar.

Here is my string:

"\ue057 " + getString(R.string.notification_sent_hey)

I've already tried using the softbank, and every format possible: "U+1F601", "\xF0\x9F\x98\x81"

What should I do?

Thanks.

Maurício Giordano
  • 3,116
  • 4
  • 32
  • 60

1 Answers1

-3

You can't do it like that. Notifications have a layout, and you are forced to use that layout.

A big icon, text, and a little icon. That's it. It's quite clearly stated here: http://developer.android.com/design/patterns/notifications.html

So, you can follow the example explained here: http://developer.android.com/training/wearables/notifications/creating.html

For example:

NotificationCompat.Builder notificationBuilder =
    new NotificationCompat.Builder(this)
    .setSmallIcon(R.drawable.ic_event)
    .setContentTitle(eventTitle)
    .setContentText(eventLocation)
    .setLargeIcon(R.drawable.ic_event2);
    .setContentIntent(viewPendingIntent);

// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
    NotificationManagerCompat.from(this);

// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
Mikel Pascual
  • 2,202
  • 18
  • 27
  • 3
    Nothing in there would prevent him from using emoji in the text of his content or title. – Gabe Sechan Jul 15 '14 at 00:25
  • So how whatsapp use emojis on the setContentText ? – Maurício Giordano Jul 15 '14 at 00:25
  • 1
    You mean in the notification area? Never seen that. If you mean in a normal textView, you can use a library (this one, for example: https://github.com/rockerhieu/emojicon). But I think that Android doesn't support emojis out of the box (correct me if I'm wrong). – Mikel Pascual Jul 15 '14 at 01:15
  • 1
    By the way, you can put html in TextViews. But this will only work on your own app (not in the notification bar). This is a good example: http://stackoverflow.com/questions/2865452/is-it-possible-to-display-inline-images-from-html-in-an-android-textview – Mikel Pascual Jul 15 '14 at 01:31