I rooted my device and working in host mode. I can able to detect the usb device connected to my tab but
Am having two questions.
1) i try to display my device name using
device.getDeviceName();
but its showing something like/dev/usb/002/002
I need to get the manufacturer name of the usb device name. I thing its available in accessory mode but i need to get the manufacturer name in host mode.
2)I need to transfer some data from my app to the usb port in android. i can able to detect the device but please help in transfering some data or file from my android app to mass storage connected to usb port.
Best Answer
Probably you will actually need to read the Raw USB Descriptors to get at the data you want. Here's a basic USB device discovery program I wrote for my own purposes. Mind you that I'm looking for a specific device (a Dajac Easy I/O 1000 data acquisition system) but you can apply the same principles. I do show you how to get the data you're looking for.
Here's the code first. My package is usbtest3, and the file is MainActivity.java:
My manifest file containing the intents and requirements for the USB Host device support:
Finally, you will need a device filter. This is located under \res\xml\device_filter.xml Note that I had to create the xml folder myself, under \res.
Note that all the fields need to be in decimal, not hex. You'll need to substitute your own vendor, product, class and subclass values from your own device. You can use a program like "USB Host View" or "USB Device Info" to discover these values. (download them free from the Play Store.)
Finally, here's how I defined the user interface in Activity_Main.xml
You'll need at least the Discover button, and the TextMultiline for output. (Ignore the Init and On/Off buttons.)
BTW, I'm using a 10" Toshiba Thrive tablet, so YMMV.
When I run my program and plug in my device, it asks for my permission to connect and I say "Ok". then I click Discover, and it tells me among other things that the manufacturer is "Dajac Inc." the product is "EIO1000" and the serial# is "0000004B".
I wish you good providence; you can give me credit but it's only by standing on the shoulders of others (with a lot of my own sweat) I've been able to see this far. Pass it forward! -David