Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show emoji on notification like Whatsapp

Tags:

android

emoji

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.

like image 254
Maurício Giordano Avatar asked Jul 15 '14 17:07

Maurício Giordano


1 Answers

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!

like image 173
Alan Poggetti Avatar answered Sep 23 '22 12:09

Alan Poggetti