jelic98
jelic98

Reputation: 713

Add emoji to Android keyboard

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.

Upvotes: 2

Views: 3952

Answers (3)

Aces Up
Aces Up

Reputation: 33

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 :)

Upvotes: 1

Sandra Sukarieh
Sandra Sukarieh

Reputation: 143

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

dependencies {

   compile 'com.rockerhieu.emojicon:library:1.0'
}

Upvotes: 1

Anton Kizema
Anton Kizema

Reputation: 1092

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)

Upvotes: 0

Related Questions