3
votes

I'm trying to communicate with a usb device, using an acer iconia a500 upgraded to android 3.2 (kernel 2.6.36.3+, not rooted, I just used the regular update feature). In a nutshell, what happens is that after I get the UsbManager, getDeviceList returns an empty map. The same happens with the adbtest sample from google:

mManager = (UsbManager)getSystemService(Context.USB_SERVICE);
// check for existing devices
for (UsbDevice device :  mManager.getDeviceList().values()) {
    // I get nothing here, the values() list is empty

I've tried several devices (various usb solid state disks, an hard drive, a mouse, a garmin watch, etc). nothing. Some devices (disks, mouse) are indeed recognized by the OS (they work: I see the filesystem, the mouse works fine, etc), but they don't get reflected at the API level.

Googling around, some people say that mouse and keyboard don't get enumerated but disks do, but they're using 3.1 while I'm using 3.2. I don't get the disk either, or anything else I've plugged in.

The code above should enumerate all devices. Anyway, I also tried the intent + xml file approach as documented in the google samples. Still nothing.

The manifest seems ok, and as I said, the adbtest sample straight from the sdk shows the same problem.

Given the paucity of the API, I don't really know what to try next. Has anybody succesfully used host mode on an iconia a500 with android 3.2?

EDIT: I mean "used" at the API level. As I said, "standard" devices gets recognized at the OS level and works, but aren't visible through the API. In the end I need to communicate with a non-standard device in host mode, so I really need to get it through the API.

EDIT 2: I'm not contemplating rooting my device because my app (if I ever manage to write it :-) would be useless if rooting was needed.

Thanks!

  • vic
2
I've used keyboard, mouse and an external NTFS hard drive with my Iconia on 3.2.Michell Bak
yes, as I said, me too. they work on they own, but don't get enumerated at the API level, so although the OS can see them, I can't (so I can't communicate with a non-standard device). I'll clarify my question, thanks!vic
You might be able to contact the developer of "Drive Mount" and hear how he's got it working. The application is here: market.android.com/details?id=au.dach.drivemountMichell Bak
I've installed the app, however it requires the device to be rooted. That's not possible for my application, and should not be required for usb host (but it's likely to be necessary to mount a drive). I'll further clarify my question, thanks.vic

2 Answers

2
votes

Make sure your intent filter is not hiding the devices.

http://developer.android.com/guide/topics/usb/host.html

"In general, use vendor and product ID if you want to filter for a specific device and use class, subclass, and protocol if you want to filter for a group of USB devices, such as mass storage devices or digital cameras. You can specify none or all of these attributes. Specifying no attributes matches every USB device, so only do this if your application requires it:"

Tell me if it works for you.

0
votes

Try this code,

mUsbManager = (UsbManager) getSystemService(USB_SERVICE);
HashMap<String, UsbDevice> devicelist = mUsbManager.getDeviceList();
Iterator<UsbDevice> deviceIterator = devicelist.values().iterator();

if (deviceIterator.hasNext()) {
    while(deviceIterator.hasNext()) {
        mUsbDeviceX = deviceIterator.next();
        if (mUsbDeviceX != null) {
            Log.v(Log_Tag, "ProdID: " +mUsbDeviceX.getProductId());
            Log.v(Log_Tag, "VendID: " +mUsbDeviceX.getVendorId());
        }
    }
} else {
    Log.v(Log_Tag, "No Usb Devices Attached");
}

If it doesn't work than show us the output of dmesg/logcat here.