How to disable emojis programmatically in Android

Try this it’s works for me editText.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 … Read more

Why does calling getWidth() on a View in onResume() return 0?

A view still hasn’t been drawn when onResume() is called, so its width and height are 0. You can “catch” when its size changes using OnGlobalLayoutListener(): yourView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Removing layout listener to avoid multiple calls if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { yourView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { yourView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } populateData(); } }); … Read more