You should find this WILL NOT work:
<Key android:codes="0x1F602" android:keyLabel="0x1F602"/>
Instead in the .xml layout file, for each emoji you want to add, create a line like this:
<!--'Face with tears of joy' -->
<Key android:codes="0x1F602" android:keyLabel="\ud83d\ude02"/>
The "\ud83d\ude02" is called a Java Escape sequence (16 bit).
If your using the standard SoftKeyboard (or some derivative), you will have to change it to handle the escape characters. You should have a class called SoftKeyboard
which extends InputMethodService
. Inside there should be a method called handleCharacter
. Change this line:
getCurrentInputConnection().commitText(String.valueOf((char) primaryCode), 0);
To this line:
getCurrentInputConnection().commitText(String.valueOf(Character.toChars(primaryCode)), 1);
Code Referenced from : display built-in emoji keys for inputmethod
Other References:
http://android.appstorm.net/how-to/customization/how-to-use-emojis-on-your-android-device/
Emoji Keyboard support for EditField in android
set font at runtime, Textview