user1992 user1992 - 11 months ago 84
Java Question

Android some unicode values (emoticons) not recognized

I'm using this code above to show some text which contains emoticons in an


EditText et = (EditText) findViewById(;
et.setText(StringEscapeUtils.unescapeJava("This is a text with emoji \u263A"));

This shows me the text I wrote and a smiley emoticon or sth.

BUT if I put another value instead of
, for example
, it doesn't work. It shows sth like the image in this question here:

Unicode character (U+1FXYZ) not outputting correctly when used in code-behind

Does anyone know how to handle this?
Thank you.


The \uXXXX is for 4 hexadecimal digits, 16 bits Unicode. Some (not java) languages use capital \UXXXXXXXX (\U0001F60A). You can use:

String emoji = new String(new int[] { 0x1F60A }, 0, 1);

This uses a code point array of just one code point.

et.setText("This is a text with emoji " + emoji);

Whether the emoji is shown depends on the font.