6

My application uses Android 4.0 on Samsung Galaxy S3.

I want to integrate Emoji character support in EditText field in Android application. Can anyone suggest me, how can I achieve it?

For example, In whatsapp and wechat application, TextField does support Emoji keyboard characters, but in my application it shows ? for each character I type using Emoji keyboard.

Screenshot explaining my need

text_message = (EditText) findViewById(R.id.editText1);
    text_view = (textView) findViewById(R.id.textView1);
    btntest = (Button) findViewById(R.id.button1);
    btntest.setOnClickListener(new OnClickListener()
    {
        public void onClick(View v)
        {

            text_swype.setText(text_message.getText().toString());
        }
    });

and i also try https://github.com/IPL/iOSStyleEditText

and font of emoji from http://klncity1.wordpress.com/tag/emoji/

but not work

HiteshGs
  • 539
  • 2
  • 7
  • 18

5 Answers5

3

It depends on the font that is used for the TextView or its subclasses like EditText.

Every View can display emoji because there are hundreds of emoji included in Unicode and those have also become the default that most emoji keyboards and apps like WhatsApp use.

However, you won't see those colorful images as you see in WhatsApp, for example. This is because WhatsApp uses custom fonts/images for these emoji which replace the default appearance.

But if you add emoji to a text field in your normal "Messages" application or somewhere else, you should see the normal Android style which is monochrome emoji showing the Android robot.

Here's a list of common emoji and their Unicode codepoints:

https://github.com/delight-im/Emoji

They're all supported in Android's normal font. I guess you may have changed the font of your EditText in the layout.

caw
  • 30,999
  • 61
  • 181
  • 291
2

You can use EmojiconTextView or EmojiconEditText from this library : https://github.com/rockerhieu/emojicon

Hieu Rocker
  • 1,070
  • 12
  • 19
  • Hi, i'm using that library and the emojis are well diplayed, but the other non emoji characters are decoded as japanese characters...What should i do? Thx – Billyjoker Mar 09 '14 at 20:29
  • Hi all i used above library it works great, But after selecting emoji icons i need to convert them to unicode characters and send to server in JSON format and display them accordingly when i received from server, I'm not sure how to unicode them. please help me. – Raj Kumar Mar 13 '14 at 15:36
  • @Billyjoker what was the text you try to display? – Hieu Rocker Apr 14 '14 at 12:09
  • @RajkumarMandera you just need to get the text of `EmojiconTextView` and `EmojiconEditText` and send to the server. They should be in unicode already. – Hieu Rocker Apr 14 '14 at 12:11
  • I figured it out, while sending text to server on POST i did not set Charset-UTF-8. Anyway thanks for your reply Hieu Rocker – Raj Kumar Apr 14 '14 at 13:12
  • i am getting error while syncing... after adding the library – Aman Verma Jan 20 '16 at 10:21
2

Here is the list of available emoji Unicode

Sending content to Server you need to use org.apache.commons.lang3.escapeJava(...) and when getting data from server you need to reverse Unicode to emoticon so you have to use org.apache.commons.lang3.unescapeJava(...)

AZ_
  • 21,688
  • 25
  • 143
  • 191
0

You have to use "EmojiconEditText" From the Library. It will display Eemojies.

Use any one of these.

EmojiconTextView: a TextView which can render emojis.
EmojiconEditText: a EditText which can render emojis.
EmojiconGridFragment: a fragment contains emojis in a GridView for the user to choose.
EmojiconsFragment: a fragment contains many set of emojis for the user to choose.
hims_3009
  • 1,737
  • 14
  • 23
0

Below is Util from org.apache.commons.lang3

Answer posted by @AZ_ is right but the util name has updated as below :

Send string to server as :

org.apache.commons.lang3.StringEscapeUtils.escapeJava(mEdText1.getText().toString()

Read String from server as :

org.apache.commons.lang3.StringEscapeUtils.unescapeJava(mData.get(position).getText())
KOTIOS
  • 11,177
  • 3
  • 39
  • 66