【问题标题】:How many usb devices connected to Android Raspbery Pi 3?有多少个 USB 设备连接到 Android Raspberry Pi 3?
【发布时间】:2016-11-01 07:28:27
【问题描述】:

我正在使用 Android Raspberry Pi 3,我想知道有多少 USB 设备连接到它。 我知道如何为相机设备做到这一点:

Log.d(TAG, "how many camera device? -->" + Camera.getNumberOfCameras());

但我不知道有多少其他 USB 设备连接到它。

谢谢。

【问题讨论】:

    标签: android raspberry-pi usb device enumeration


    【解决方案1】:

    Andoid USB Host guide 中所述,您可以枚举 USB 主机设备:

    UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
    
    HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
    Log.v(TAG, "There are : " + deviceList.size() + " USB devices connected");
    

    您可以使用 :

    对其进行迭代
    Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
    while(deviceIterator.hasNext()){
        UsbDevice device = deviceIterator.next();
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-10
      • 2017-06-02
      • 2015-12-17
      • 1970-01-01
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多