是否可以同时启用物理键盘和软键盘?

发布于 2024-12-04 21:17:53 字数 299 浏览 0 评论 0原文

我的应用程序需要同时激活两个输入源:条形码扫描仪和软键盘。当我配对蓝牙扫描仪时,它被视为物理键盘。因此,当连接该设备时,不会显示软键盘(软键盘已停用)。

是否可以同时启用物理键盘和软键盘? 如果不是,解决问题的最佳方法是什么?我是否必须实现一个自定义视图来接收按键事件?市场上有任何键盘应用程序可以做到这一点吗?

如何以编程方式打开和关闭物理键盘?这是切换按钮“使用物理键盘”设置(我在这里找到了此设置的屏幕截图:

在此处输入图像描述

My Application needs to have two sources of input active at the same time: A bar-code scanner and the soft keyboard. When I pair a blue-tooth scanner, it is being treated as a physical keyboard. So, when this device is connected, the soft keyboard is not being displayed (soft keyboard is deactivated).

Is it possible to have both Physical Keyboard and Soft Keyboard active at the same time?
If not, what is the best approach towards solving the problem? Do I have to implement a custom View that sinks key press events? Is there any keyboard App on the Market that does this?

How do I, programatically, turn the Physical Keyboard On and Off? This is the toggle button 'Use Physical Keyboard' setting (I found the screenshot of this setting here:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2024-12-11 21:17:53

物理键盘和软键盘无法同时处于活动状态。它由 InputMethodService 函数 onEvaluateInputViewShown 强制执行。您可以在此处查看文档

/**
 * Override this to control when the soft input area should be shown to
 * the user.  The default implementation only shows the input view when
 * there is no hard keyboard or the keyboard is hidden.  If you change what
 * this returns, you will need to call {@link #updateInputViewShown()}
 * yourself whenever the returned value may have changed to have it
 * re-evaluated and applied.
 */
public boolean onEvaluateInputViewShown() {

因此,除非您正在实现自己的 IME,其中您可以覆盖 onEvaluateInputViewShown,否则不可能同时激活物理键盘和软键盘。

关于你的最后一个问题,我不确定,但我认为没有办法以编程方式隐藏硬键盘。虽然它没有解决方案,但您应该检查 这个问题

It is not possible to have both Physical Keyboard and Soft keyboard active at the same time. It is enforced by InputMethodService function onEvaluateInputViewShown. you can check the documentation here.

/**
 * Override this to control when the soft input area should be shown to
 * the user.  The default implementation only shows the input view when
 * there is no hard keyboard or the keyboard is hidden.  If you change what
 * this returns, you will need to call {@link #updateInputViewShown()}
 * yourself whenever the returned value may have changed to have it
 * re-evaluated and applied.
 */
public boolean onEvaluateInputViewShown() {

So unless you are implementing your own IME wherein you can overide onEvaluateInputViewShown it is not possible to have both Physical and softkeyboard to be active at the same time.

Regarding your last question i am not sure but I think there is no way to programmatically hide the hardKeyboard. Though it doesn't have the solution you should check this question

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文