29

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 barcode reader which works fine.

My problem is that once the barcode reader is plugged in, it's recognized as a real keyboard, and I can't access the virtual keyboard anymore. This is a big issue for me, because I only use the barcode reader to encode EAN13 codes, and need the soft keyboard beside...

Is there any way to enable both virtual and real keyboards ? I really need help on this....

Thank you !

Lapin-Blanc
  • 1,945
  • 1
  • 17
  • 26
  • Saving for use later, I will have to solve the exact same problem some time down the road :) – Kitalda Jul 03 '15 at 09:25
  • Hi.. Do you get any solution for this issue.. I too need to enter barcodes manually and from barcode scanner too.. But my android version 4.2.2 not permits me to open the on screen keyboard when barcode scanner is connected. – kumar Sudheer Nov 04 '16 at 12:46
  • @kumarSudheer have you already find a way ?? I have exact the same problem, have an android device with a physical input device and while the physical device is plugged the softkeyboard is always hidden – feldeOne Jun 14 '17 at 14:12
  • [just check this answer, it might be the one you are looking for](https://stackoverflow.com/a/55321957/8774798) – Muhammed Ashraf Mar 24 '19 at 08:37

7 Answers7

18

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 !

Lapin-Blanc
  • 1,945
  • 1
  • 17
  • 26
  • 1
    is this possible in a single screen where two edittext are there, and i want to show soft keyboard on one edittext and hide on another. because on focus on second edittext, want to scan barcode. – Hiren Dabhi Feb 12 '13 at 06:22
  • Just to clarify for Lollipop on tablet: Install some 3rd party keyboard. Swiping down from the top will allow you to go directly to language and input settings. Choose the keyboard you want (does not have to be the 3rd party one), now the soft keyboard should show even though a physical keyboard is attached. – Kitalda Jul 22 '15 at 09:47
  • On a tablet (Polaroid) with v4.1.1 this option doesn't work :( THIS works: System Settings, Language & input, Default (under Keyboard & Input Methods), toggle Hardware Physical Keyboard Off. The setting doesn't stick on restarts or HW disconnect/reconnect – gregg Dec 10 '15 at 19:08
  • This works!! However, can we programmatically switch it to "No"? – Yeung Feb 17 '16 at 04:02
15

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();
  }
}
desidigitalnomad
  • 1,443
  • 21
  • 33
  • here is my solution (no in onConfiguration... but in onResume and onFocus) http://stackoverflow.com/a/38467241/2233069 – djdance Jul 19 '16 at 19:47
  • onConfigurationChanged event is given in the Application class. This way, we can detect scanner plugged in anywhere in the app. – desidigitalnomad Jul 20 '16 at 06:31
  • aaRBiyecH, this not work in common case if scanner already (always) plugged – djdance Jul 20 '16 at 09:56
  • Once you connect the scanner, you have to turn off hardware keyboard from settings. You can use both soft keyboard and scanner till you remove and conenct the scanner – desidigitalnomad Jul 21 '16 at 05:29
  • correct. Im talking just about the call point for check/ask function. – djdance Jul 21 '16 at 10:16
11

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);
rekire
  • 47,260
  • 30
  • 167
  • 264
5

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);
muneikh
  • 2,067
  • 5
  • 25
  • 59
  • Thank you Maverick, this would be a great answer if I was developing an android app, but as I said earlier, I'm only using the tablet to access the django application via a browser. Btw I found the solution by myself. – Lapin-Blanc May 20 '12 at 13:58
  • 2
    Above code is not working when an external keyboard is attached already. – Napolean Jul 13 '15 at 08:56
2

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.

HuhtaPike
  • 39
  • 1
1

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

It worked for me after I enabled Use on-screen keyboard (Keep it on screen while physical keyboard is active) in Languages & input > Keyboard, mouse, and track pad.

jare25
  • 506
  • 1
  • 7
  • 17