0

There is a requirement for not allowing to display the option of Smileys on the Android soft keyboard. We are testing this on 2 different types of keyboards :

  1. Gboard
  2. Default Samsung keyboard

Scenario 1: On Gboard I do not see the option for displaying Smileys : This is expected

enter image description here

Scenario 2: On default Samsung keyboard, I can still see the option for displaying Smileys : Not expected

enter image description here

Below are the few solutions which I have tried : mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD| TEXT_MULTILINE);

and

android:inputType="textEmailAddress"

from here : How to disable emoji from being entered in Android EditText?

but no luck.

Can someone please help to look into this issue since this is a must have functionality for us.

  • You could downloaded an older version of gboard from apkpure and installed it, this is the gboard version Gboard the Google Keyboard_v8.8.8.276639079-release-arm64-v8a_apkpure.com.apk. **Edit:** after installing the older version go the play store and look for gboard and turn off auto update – Lucas Zhang Jun 06 '20 at 06:24

2 Answers2

0

Can you try below code on your EditText?

private void disableEmojiInTitle() {
InputFilter emojiFilter = new InputFilter() {
    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        for (int index = start; index < end - 1; index++) {
            int type = Character.getType(source.charAt(index));

            if (type == Character.SURROGATE) {
                return "";
            }
        }
        return null;
    }
};
editText.setFilters(new InputFilter[]{ emojiFilter });

}

you can add below type as well to exclude other symbols also

type==Character.OTHER_SYMBOL
Prashant.J
  • 739
  • 7
  • 12
0

To disable emoji button on Samsung default soft keyboard use the below

yourEditText.setPrivateImeOptions("disableEmoticonInput=true;");

the flag for other keyboards is not so much known so it could be difficult.

czane
  • 392
  • 1
  • 6
  • 18