Emoji on Android Notification

我只是一个虾纸丫 提交于 2019-12-10 20:38:45

问题


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.


回答1:


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());


来源:https://stackoverflow.com/questions/24747886/emoji-on-android-notification

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!