UsbSerial icon indicating copy to clipboard operation
UsbSerial copied to clipboard

getDeviceList empty

Open aprldntm1234 opened this issue 3 years ago • 2 comments

I developed a program using this library. HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList(); Log.d("usbDevices_log", usbDevices.toString());

where usbManager.getDeviceList(); When I output the value as log, it came out empty.

Is there no solution? For reference, the current version is 5.1.1 Lollipop.

image

aprldntm1234 avatar Feb 16 '22 05:02 aprldntm1234

hey, did your problem solved?

davdavcoco avatar Nov 04 '22 03:11 davdavcoco

The UsbManager.getDeviceList() method is a standard USB-Host method in Android. So it's not the felHR85-UsbSerial library's fault.

Returns a HashMap containing all USB devices currently attached. USB device name is the key for the returned HashMap. The result will be empty if no devices are attached, or if USB host mode is inactive or unsupported. Requires the PackageManager#FEATURE_USB_HOST feature which can be detected using PackageManager.hasSystemFeature(String).

Did you use an Android emulator that Android Studio provided to run your app? In that case, It is not supported.

https://developer.android.com/studio/run/advanced-emulator-usage#limitations

Some non-standard Android devices require OTG support to be enabled (in their setting) before using any USB serial adapter.

If you don't attach any USB serial adapter, the UsbManager.getDeviceList() method will return an empty list.

Other than that, try to check USB Host support for your hardware device with this app from Google Play Store: https://play.google.com/store/apps/details?id=eu.chainfire.usbhostdiagnostics

eclectice avatar Nov 04 '22 07:11 eclectice