条形码扫描仪连接到平板电脑时,软键盘无法正常工作

sun*_*nil 5 android

InputMethodManager imm = (InputMethodManager)getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
Run Code Online (Sandbox Code Playgroud)

使用此代码时,条形码扫描仪连接时也不会出现软键盘请帮忙

小智 2

我找到了解决方案,它适用于 Nexus 4.4.2

if(getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO){
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showInputMethodPicker();
    }
Run Code Online (Sandbox Code Playgroud)

您必须在弹出消息中禁用硬件键盘。