无法看到鼠标和键盘设备与Android的usbManager [英] Can't see mouse and keyboard device with usbManager android

查看:700
本文介绍了无法看到鼠标和键盘设备与Android的usbManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个项目,我需要得到服务上的键盘和鼠标的数据。我还必须能够将数据发送到我的设备藏了起来。要做到这一点,我想使用USB HOST模式。当我的设备列表中,我可以看到一个大容量存储,但没有鼠标和键盘。搜索后,我已经看到了usbManager不返回鼠标和键盘设备。我试图更改权限whitout成功)(/系统的/ etc /权限)。
我已经运行应用程序 USB设备信息,然后我看到鼠标和键盘Linux设备,而不是在Android设备上。

I work on a project where I need get data of keyboard and mouse on a service. I also have to be able to send data to my device hid. To do this, I want use the usb host mode. When I get list of device, I can see a mass storage but no mouse and keyboard. After search, I have seen that usbManager don't return mouse and keyboard device. I have tried to change permissions (on /system/etc/permissions) whitout success). I have run the application USB Device Info and I see mouse and keyboard on linux device and not on android devices.

我使用Android 4.2.2。
是否有可能获得鼠标(和键盘)与USB主机的HID数据,或者我要找到一个其他的方式?

I use android 4.2.2. Is it possible to get hid data of mouse (and keyboard) with usb host or I have to find an other way ?

感谢您的帮助。

推荐答案

您可以通过InputManager检测鼠标/键盘:

You can detect mouse/keyboard via InputManager:

if(Build.VERSION.SDK_INT > 15) {
    InputManager inptmgr = (InputManager)getSystemService(INPUT_SERVICE);
    int[] inputs = inptmgr.getInputDeviceIds();
    for(int i = 0;i<inputs.length;i++) {
        String devicename = inptmgr.getInputDevice(inputs[i]).getName();
        if(devicename.toLowerCase().contains("mouse")) {

        } else if(devicename.toLowerCase().contains("keyboard")) {

        }
    }
}

至于你可能想收集任何其他数据,你可以浏览下中的所有其他方法getInputDevice() getVendorId() getProductId() getMotionRange() getKeyCharacterMap() ,及其他。

希望这有助于!

这篇关于无法看到鼠标和键盘设备与Android的usbManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆