display built-in emoji keys for inputmethod
Asked Answered
S

4

10

I'm building a custom soft keyboard for android and would like to add a layout to include the emoji keys similar to what the default android keyboard (AOSP) is doing. I've searched around but it seems that most people are trying to display custom emoji from images. I'm looking to show the built-in icons that comes with Android (as shown below):

Android built-in emoji

It seems that I should be able to use the Unicode characters to send images from the keyboard, but my first attempt seems to generate only the older versions of the emojis. How do I support the latest emoji the phone can handle? Also, how do I display the emojis in my keyboard as in the image above?

Shaia answered 2/5, 2015 at 16:17 Comment(1)
Anyone has any ideas?Shaia
S
3

Thanks for all the suggestions. What I got to work for showing an emoji layout in my custom keyboard was the following:

  1. In the .xml layout file, for each emoji you want to add, create a line like this: <Key android:codes="0x1F602" android:keyLabel="\ud83d\ude02"/>

  2. When committing the key, use: getCurrentInputConnection().commitText(String.valueOf(Character.toChars(primaryCode)), 1);

Shaia answered 28/7, 2015 at 2:45 Comment(0)
C
5

Emoticons-Keyboard

1) instead emitos ,Iam replacing the ImageView containing an asset with a TextView containing a Unicode sequence.

After cross referencing Supported Unicode Sequences as well as the Visual Unicode Database I realized that **u1F601** was a 32 bit Unicode representation, and the 16bit representation can be set like :

EditText messageInput = (EditText) findViewById(R.id.message_input);
messageInput.getText().append("\ud83d\ude01");

2) http://android.appstorm.net/how-to/customization/how-to-use-emojis-on-your-android-device/

Changteh answered 20/7, 2015 at 10:43 Comment(0)
P
4

Go to https://en.m.wikipedia.org/wiki/Emoji to see which emojis your device supports with unicode.

As you know which emoji is shown depends on the font you use, so to get the latest emojis use NotoColorEmoji.ttf as font for your app.

Patronizing answered 15/7, 2015 at 12:4 Comment(2)
Thanks. However, my phone supports the same set of icons as shown in screenshot above. I don't know why it displayed older icons when I sent the corresponding unicode sequence. Also, how I can get a view on my custom keyboard showing these emoticons as in the screenshot above?Shaia
assuming you use textviews in your keyboard: stackoverflow - set-font-at-runtime-textviewPatronizing
S
3

Thanks for all the suggestions. What I got to work for showing an emoji layout in my custom keyboard was the following:

  1. In the .xml layout file, for each emoji you want to add, create a line like this: <Key android:codes="0x1F602" android:keyLabel="\ud83d\ude02"/>

  2. When committing the key, use: getCurrentInputConnection().commitText(String.valueOf(Character.toChars(primaryCode)), 1);

Shaia answered 28/7, 2015 at 2:45 Comment(0)
B
2

Emoticon support doesn't work like you think it does. There is no universal set of emojis supported by all android devices, and the emojis your device does support may show differently on different devices. Emojis are done on Android in 1 of 2 ways.

1)Unicode. What emojis the device supports then depends on the font the app is using. You just send the unicode just like you would normal text, and you'd display it on your keyboard by displaying that character. For this method, you guess on which ones the phone will support. And its a total guess, because it depends on what font the app is using.

2)Image spans. You embed an ImageSpannable into the text you send via commitText. The advantage of this is you're sure you have an image (you need to include the images with your app). The disadvantage is it can't be sent to another device, saved, and may not work in all apps (they may not be displaying spannable objects).

Balneology answered 20/7, 2015 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.