How to enable both hardware and virtual keyboards on Android ice cream sandwich

前端 未结 6 1345
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 13:47

I\'m developping a stock management application with Django for a customer\'s company, and want to use an ice cream sandwich tablet as the end-user device. I use an USB barc

6条回答
  •  误落风尘
    2020-12-05 14:04

    Yes, the barcode scanner is detected as a Physical Keyboard. When a keyboard is connected to the device, by default the soft keyboard is disabled. To enable it, we need to turn OFF hardware keyboard via:

    Settings > Language & Input > Select Input Method

    The option name may differ from device to device. We will be able to use the scanner along with the soft keyboard even though we turn it OFF.

    And NO, there is no way currently to programmatically accomplish this. The most we can do is detect when a scanner/keyboard is connected and redirect the user to the Input Method selection window, by overriding the onConfigurationChanged method like this:

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
      super.onConfigurationChanged(newConfig);
      if(newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
    
        ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
                                      .showInputMethodPicker();
        Toast.makeText(this, "Barcode Scanner detected. Please turn OFF Hardware/Physical keyboard to enable softkeyboard to function.", Toast.LENGTH_LONG).show();
      }
    }
    

提交回复
热议问题