How to set emoji by unicode in a textview? How to set emoji by unicode in a textview? android android

How to set emoji by unicode in a textview?


Found a solution:

In my unicode I replaced 'U+' by '0x'

Example: replace 'U+1F60A' by '0x1F60A'

This way I got an 'int' like

int unicode = 0x1F60A;

Which can be used with

public String getEmojiByUnicode(int unicode){    return new String(Character.toChars(unicode));}

So Textview displays 😊 without Drawable

Try it with http://apps.timwhitlock.info/emoji/tables/unicode


You can directly use Emojis in string resources by using the decimal code like this:

😊

for example:

<string name="emoji">I am happy &#128522;</>


Note: For Kotlin

fun getEmoji(unicode: Int): String {    return String(Character.toChars(unicode))}