16

デフォルトのAndroidソフトキーボードを使用していない場合にユーザーに警告したいアプリケーションがあります。(つまり、Swypeまたは他のものを使用しています)。

彼らが現在選択している入力方法を確認するにはどうすればよいですか?

4

3 に答える 3

26

デフォルトのIMEを取得するには、次を使用します。

Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
于 2010-11-23T13:41:06.110 に答える
6

InputMethodManager持っていgetEnabledInputMethodList()ます。InputMethodManagerあなたはあなたのからを取得getSystemService()しますActivity

于 2010-04-30T13:38:57.277 に答える
2

これは、GoogleKeyboard、Samsung Keyboard、またはSwypeKeyboardのいずれが使用されているかを判断するために使用したコードです。mCurIdのリフレクションによって返される値は、IMEIDを示します。

探しているさまざまなキーボード/入力方法でテストして、関連するものを見つけてください

public boolean usingSamsungKeyboard(Context context){
    return usingKeyboard(context, "com.sec.android.inputmethod/.SamsungKeypad");
}

public boolean usingSwypeKeyboard(Context context){
    return usingKeyboard(context, "com.nuance.swype.input/.IME");
}

public boolean usingGoogleKeyboard(Context context){
    return usingKeyboard(context, "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME");
}   

public boolean usingKeyboard(Context context, String keyboardId)
    {
        final InputMethodManager richImm =
          (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);

        boolean isKeyboard = false;

        final Field field;
        try
        {
            field = richImm.getClass().getDeclaredField("mCurId");
            field.setAccessible(true);
            Object value = field.get(richImm);
            isKeyboard = value.equals(keyboardId);

        }
        catch (IllegalAccessException e)
        {

        }
        catch (NoSuchFieldException e)
        {

        }
        return  isKeyboard;
    }
于 2019-08-26T15:07:47.190 に答える