Show emoji on notification like Whatsapp

时光毁灭记忆、已成空白 提交于 2019-12-07 03:13:27

问题


I need to show some emojis on setContentText on NotificationCompat like Whatsapp shows.

I have tried to use the softbank and some variations, nothing work. (see Emoji on Android Notification) Like Gabe Sechan suggested, probably the default font on NotificationCompat doesn't support emojis.

Is there a way to change the default font on NotificationCompat? If not, how does whatsapp shows emojis on its notifications?

Thanks.


回答1:


This is the only way I got it working:

Spanned mssg;
mssg = Html.fromHtml(URLDecoder.decode("%F0%9F%98%82"));

It may vary depending on how do you receive your text, in my case i'm sending the emojicons using unicode to a GCM server and I don't have to worry about the URLDecoder, but if I receive a message sent from a emojicon PHP library and not from an android device the only way to show it properly was with the URLDecoder.

So if you're working with GCM it should be working with just

Spanned mssg;
mssg = Html.fromHtml(intent.getStringExtra("message"));

Hope it helps!



来源:https://stackoverflow.com/questions/24764723/show-emoji-on-notification-like-whatsapp

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