1

When i am trying to enter password then i am getting emoji option in my soft input keyboard. So guys does any one has any idea how to remove this emoji option from soft input keyboard if my input type is textpassword

screen one

screen two

Faisal Khan
  • 2,574
  • 3
  • 20
  • 36

1 Answers1

3

Customize the view.

    public class CustomEditText extends EditText {
    public CustomEditText(Context context) {
        super(context);
        init();
    }

    public CustomEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        setFilters(new InputFilter[]{new EmojiExcludeFilter()});
    }

    private class EmojiExcludeFilter implements InputFilter {

        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            for (int i = start; i < end; i++) {
                int type = Character.getType(source.charAt(i));
                if (type == Character.SURROGATE || type == Character.OTHER_SYMBOL) {
                    return "";
                }
            }
            return null;
        }
    }
}
W4R10CK
  • 5,502
  • 2
  • 19
  • 30
  • 2
    Doesn't remove the emoji option from the keyboard, but stops the emoji being entered which is what I need, thanks – Kibi Dec 03 '17 at 12:51