UsbManager.getDeviceList() returns empty

前端 未结 4 773
南笙
南笙 2020-12-21 05:46

I want to use the UsbManager API by wrote following code:

In the Activity code:

        UsbManager manager = (UsbManager) getSystemServi         


        
4条回答
  •  孤城傲影
    2020-12-21 06:07

    This code works fine for me. Although your code looks similar you can recheck.

      UsbManager usbManager = (UsbManager) getSystemService(USB_SERVICE);
      HashMap map = usbManager.getDeviceList();
      Iterator it = map.values().iterator();
    
      while(it.hasNext()) {
        UsbDevice device = it.next();
        // use device info
      }
    

提交回复
热议问题