Insert emotions into input editor (IME?)

How can I insert emoji / smiley / emoticons into the input method editor (on a soft keyboard)? What method should I use for this purpose?

  • To create a true type font? (I think the font has one color)
  • To use SpannableStringBuilder and set emoticons to a string in it?
  • or another method?

NOTE. I do not request a code. Just for the method.


Note:

I used the following function:

public CharSequence addSmileySpans(CharSequence text) { Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.smiley); SpannableStringBuilder builder = new SpannableStringBuilder(text); builder.setSpan(new ImageSpan(this,bm), 1,3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return builder; } 

and I called him that

 getCurrentInputConnection().setCommitText(addSmileySpans("123"),1); 

As a result, 123 was printed in the editor without an emoticon.

+4
source share

All Articles