Emoji on Android Notification

2019-07-04 06:13发布

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.

标签: android emoji
1条回答
Animai°情兽
2楼-- · 2019-07-04 06:49

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());
查看更多
登录 后发表回答