If you don't want to allow users to add emoji in edittext then below few lines will be helpfull for you. This method will return blank string while typing any similies/emoji in your editext.
public static InputFilter EMOJI_FILTER = new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
for (int index = start; index < end; index++) {
int type = Character.getType(source.charAt(index));
if (type == Character.SURROGATE) {
return "";
}
}
return null;
}
};
call this EMOJI_FILTER in your onCreate() method with edittext whome you have to avoid typing emoticons.
yourEdittext.setFilters(new InputFilter[]{AppUtility.EMOJI_FILTER});
0 Comment(s)