如何在 Android 冰淇淋三明治上同时启用硬件和虚拟键盘

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10561760/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:10:51  来源:igfitidea点击:

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

android

提问by Lapin-Blanc

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.

我正在使用 Django 为客户公司开发库存管理应用程序,并希望使用冰淇淋三明治平板电脑作为最终用户设备。我使用了一个工作正常的 USB 条码阅读器。

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...

我的问题是,一旦插入条形码阅读器,它就会被识别为真正的键盘,而我无法再访问虚拟键盘。这对我来说是个大问题,因为我只使用条码阅读器来编码 EAN13 代码,并且需要旁边的软键盘......

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

有没有办法同时启用虚拟键盘和真实键盘?我真的需要这方面的帮助......

Thank you !

谢谢 !

采纳答案by Lapin-Blanc

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 !

我发现即使这样,条码阅读器仍将处于活动状态(是的!)并且软键盘也会弹出!

回答by desidigitalnomad

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 onConfigurationChangedmethod like this:

不,目前没有办法以编程方式实现这一点。我们能做的最多是检测扫描仪/键盘何时连接并将用户重定向到输入法选择窗口,onConfigurationChanged方法如下:

@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();
  }
}

回答by desidigitalnomad

You could use InputMethodManager to force the software keyboard open:

您可以使用 InputMethodManager 强制打开软件键盘:

InputMethodManager imm = (InputMethodManager)getContext().getSystemService(
                                              Context.INPUT_METHOD_SERVICE); 
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

回答by muneikh

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);

回答by HuhtaPike

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.

我不是程序员,但在这里都发布了相同的问题。在网上搜索了很多之后,我通过 Google Play 商店找到了一个似乎对我们有用的键盘(BT Scanner 并且同时想要 SoftKeyboard)。它被 Klaus Weidner 称为 Hacker's Keyboard。

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.

只需使用黑客键盘,转到设置--> 向下滚动到“语言和输入”--> 黑客键盘--> 转到--> 配置--> 向下滚动到“输入模式设置”--> 确保“始终显示软键盘”已选中。即使扫描仪通过蓝牙连接,软键盘也会保持工作状态。在断开和重新连接蓝牙扫描仪时也能正常工作。

回答by Pedro Velez

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)

由于图标未显示,因此不适用于常用键盘。您需要安装另一个键盘应用程序或键盘切换器应用程序(即使您不安装任何其他键盘,它也只会显示图标)