Android: switch to a different IME programmatically

前端 未结 3 505
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 06:17

http://developer.android.com/guide/topics/text/creating-input-method.html#GeneralDesign reads:

Because multiple IMEs may be installed on the device, provide a wa

3条回答
  •  爱一瞬间的悲伤
    2020-12-30 06:26

    You cannot change the user's currently active IME through code for security reasons, sorry.

    However, you can show a system provided dialog to allow the user to select one of the other enabled ones.

    InputMethodManager imeManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 
    if (imeManager != null) {
        imeManager.showInputMethodPicker();
    } else {
        Toast.makeText(context ,"Error", Toast.LENGTH_LONG).show();
    }
    

提交回复
热议问题