2

I'm making my own custom keyboard and I have a problem with adding emoji to it. As a android:keyIcon I have a drawable of that emoji and I need android:codes for it. I don't know what to output when emoji is pressed. I've looked online for a solution, but I haven't found anything. Does anyone know what code should I use to output an emoji. Thanks in advance.

Here is a part of the xml code:

 <Row>
    <Key android:codes="1F926" android:keyIcon="@drawable/e415" />
    <Key android:codes="U+1F601" android:keyIcon="@drawable/e415" />
    <Key android:codes="57430" android:keyIcon="@drawable/e0415" />
</Row>

When I click on first or second the output is empty and when I click on the second the output is some Chinese letter.

jelic98
  • 723
  • 1
  • 12
  • 28
  • I think this guy here have a great answer http://stackoverflow.com/questions/26893796/how-set-emoji-by-unicode-in-android-textview – goose Jan 23 '17 at 07:15

3 Answers3

1

If you are using android studio this would help (in build.gradle file):

dependencies {

   compile 'com.rockerhieu.emojicon:library:1.0'
}
Sandra Sukarieh
  • 133
  • 1
  • 16
1

You should not need to add any emoji libraries or change gradle file at all. Example (XML):

<Key android:keyLabel="\u2665" android:keyOutputText="\u2665"/>

Use emoji unicode, without +, add \ before the code to use escape sequence. (emoji spade used in above example).

use keyIcon with your graphic instead of keyLabel if needed :)

Aces Up
  • 33
  • 6
  • I hope this was the answer you were looking for, it was taken directly from android developer docs – Aces Up Jul 22 '20 at 02:59
0

I have written custom keyboard recently. I used combination of this lib -

https://github.com/rockerhieu/emojicon (IOS-styled emoji)

and file i have uploaded here - http://www.ex.ua/116630385444

You have to parse file nad get all the codes. To properly visualize emoji use views from lib I mentioned above

The benefits would be that on all androids users would see emoji, unlike built-in ones (on some 4.2 and 4.4 androids there are only 3 (!) built-in emoji)

Anton Kizema
  • 1,072
  • 3
  • 13
  • 27
  • Thank for reply. I added the dependency, but I still don't know how to put this grid of emoji in `KeyboardView` and how to use this array of strings in Java. Please help me with that. If you need a code just ask. – jelic98 Aug 16 '15 at 10:08
  • Actually my keyboard was not the keyboard you are writing to implement - it is an analogue - when some buttom is clicked, I just hide normal keyboard and open(inflate) my custom layout with view instances from https://github.com/rockerhieu/emojicon wich represent different emojis. If you implement keyboard to replace android keyboare i can not halp, sorry. I digged it some times before, and sadly, there is little info on this topic. Maybe you can consider approach as mine - in your app hide regular keyboard, and make visible your custom layout with keyboard with normal Views – Anton Kizema Aug 16 '15 at 12:54
  • I'm building my own keyboard(type "Ecloga Keyboard" on PlayStore), not application. Can you tell me how show emoji keyboard in other apps. When I click on emoji button on my own keyboard, it should hide itself and show this emoji keyboard you have given me. Do you understand what am I trying to say? If you can't help me with that than please tell me what text/code should I print when some emoji is clicked. Thanks for helping me out. – jelic98 Aug 16 '15 at 13:07
  • About your second question - you must print unicode text. But I do not know if regular views handle them properly, as I mentioned I used views from the lib. And I do not know native keyboard API, can not help with this – Anton Kizema Aug 17 '15 at 09:53