Android UsbManager返回空设备列表

时间:2017-10-08 06:27:03

标签: android usb

我正在使用https://developer.android.com/guide/topics/connectivity/usb/host.html

中的示例

getDeviceList()为空

实例化UsbManager

 UsbManager mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);

 HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();      

 Log.e("usb manager", deviceList.toString());

Manifet文件

      <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
        <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />

        <meta-data
            android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
             />
    </intent-filter>

 <uses-feature android:name="android.hardware.usb.host" />
    <uses-permission android:name="android.hardware.usb.host"/>

0 个答案:

没有答案