I can see emojis if I enter unicode directly and convert it to String
with a method like:
int intUnicode = 0x1F601;
public String getEmojiByUnicode(int unicode) {
return new String(Character.toChars(unicode));
}
But I just can't wrap my head around how to convert when the unicode value is a String
like:
String strUnicode = "0xf601";
How to covert it to an Integer
like I did it directly. When I try to use Integer.parseInt(strUnicode)
compiler throws an error every time.
InputStream is = assetManager.open("emoji_unicode.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
if (is != null){
try {
while ((data = reader.readLine()) != null){
sbuffer.append(data + "\n");
String j = sbuffer.toString().trim();
int k = Integer.parseInt(j,16);
String l = getEmojiByUnicode(k);
emoArray.add(l);
}
btn.setText(emoArray.get(5));
is.close();
}catch (IOException e){
e.printStackTrace();
}
}
It's not very hard, I know I'm very close but still it won't get to me. Any help would be very appreciated. Regard