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

前端 未结 6 1321
伪装坚强ぢ
伪装坚强ぢ 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();
      }
    }
    
    0 讨论(0)
  • 2020-12-05 14:07

    Well, I found a solution to my problem ! (Don't know what to about the bounty now...)

    When you enter a text area (eg : on the navigator), you just have to touch the keyboard icon on the left of the clock. There beside "Use physical keyboard", you have to choose "No".

    I found that even like that, the barcode reader will still be active (yessss !) and the soft keyboard will popup too !

    0 讨论(0)
  • 2020-12-05 14:19

    You could use InputMethodManager to force the software keyboard open:

    InputMethodManager imm = (InputMethodManager)getContext().getSystemService(
                                                  Context.INPUT_METHOD_SERVICE); 
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    
    0 讨论(0)
  • 2020-12-05 14:21

    I am not a programmer but have the same issues all here have posted. After much digging around online, I found a keyboard thru the Google Play store that seems to work great for us (BT Scanner & want SoftKeyboard at the same time). It's called Hacker's Keyboard by Klaus Weidner.

    Just use Hackers Keyboard, go to Setting--> scroll down to "Language & Input" --> Hacker's Keyboard --> go to --> Configurations --> Scroll down to "INPUT MODE SETTINGS" --> Make sure "Show Soft Keyboard Always" is checked. The Softkeyboard will stay up even if the scanner is connected via bluetooth. Works as well when disconnecting and reconnecting the Bluetooth scanner.

    0 讨论(0)
  • 2020-12-05 14:22

    Try this to force to open soft keyboard:

    ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    

    To close back the soft keyboard:

    ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(_pay_box_helper.getWindowToken(), 0);
    
    0 讨论(0)
  • 2020-12-05 14:23

    Doesn't work with the stock keyboard as the icon does not show. You need either another keyboard app installed or a keyboard switcher app (even if you don't install any other keyboard, it will just show the icon)

    0 讨论(0)
提交回复
热议问题