我的表情符号软键盘不支持 android 中的消息编辑文本字段

My Emoji Soft Keyboard is not supporting for Message EditText Field in android

我的表情符号软键盘不支持 android 中的消息编辑文本字段。 但其他应用程序如 WhatsApp 确实支持。 例如,在 whatsapp 和微信应用程序中,TextField 确实支持 Emoji 键盘字符,但在我的移动消息 TextField 中它显示?或 _ 对于我使用表情符号软键盘键入的每个字符。 我想在 Android 应用程序的 Mobile Messaging EditText 字段中集成 Emoji 字符支持。

如果有人能给我解决这个问题的方法,我将非常感谢你的回答。

找到解决方案:

我是我的 unicode 我将 'U+' 替换为 '0x'

示例:将 'U+1F60A' 替换为“0x1F60A”

这样我得到了一个 'int' 像 :

int unicode = 0x1F60A;
String text = String.valueOf(Character.toChars(unicode));
inputConnection.commitText(text, mComposing.length());

看我的GSM短信文字版android4.2.x:

看我的另一条消息文字版android4.4.2

这里显示另一个这样的文本框:

尝试 http://apps.timwhitlock.info/emoji/tables/unicode

试试吧:

int unicode = 0x1F60A;
                    String text = String.valueOf(Character.toChars(unicode));
                    //inputConnection.commitText(text,mComposing.length());
                    mComposing.append(text);
                    sss.append(text);
                    commitTyped(getCurrentInputConnection());

另一个回答:

public void onKey(int primaryCode, int[] keyCodes) {
        if (primaryCode == -100000) {
            int unicode = 0x1F349;
            String text = String.valueOf(Character.toChars(unicode));
            mComposing.append(text);
            commitTyped(getCurrentInputConnection());
        } else if (isWordSeparator(primaryCode)) {
            if (mComposing.length() > 0) {
                commitTyped(getCurrentInputConnection());
            }
            sendKey(primaryCode);
            updateShiftKeyState(getCurrentInputEditorInfo());
        } else if (primaryCode == Keyboard.KEYCODE_DELETE) {
            handleBackspace();
        } else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
            handleShift();
        } else if (primaryCode == Keyboard.KEYCODE_CANCEL) {
            handleClose();
            return;
        } else if (primaryCode == LatinKeyboardView.KEYCODE_OPTIONS) {
            // Show a menu or somethin'
        } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE && mInputView != null) {
            Keyboard current = mInputView.getKeyboard();
            if (current == mSymbolsKeyboard || current == mSymbolsShiftedKeyboard) {
                current = mQwertyKeyboard;
            } else {
                current = mSymbolsKeyboard;
            }
            mInputView.setKeyboard(current);
            if (current == mSymbolsKeyboard) {
                current.setShifted(false);
            }
        } else {
            handleCharacter(primaryCode, keyCodes);
        }
    }

只需设置您的表情符号 xml 代码是用户定义的(111222) 例如-

<key android:codes="111222" android:keyIcon="@drawable/smiley"/>

然后软键盘中的 onkey() 方法实现如下:

public void onKey(int primaryCode, int[] keyCodes){

----
----   

else if(primaryCode == 111222){
    int codeOfEmoji= 0x1F60A;
        String text = String.valueOf(Character.toChars(codeOfEmoji));
                        mComposing.append(text);
                        sss.append(text);
                        commitTyped(getCurrentInputConnection());
    }
----
----
}

做这个过程做每一个表情符号集。这是处理这个问题的非常简单的过程。