Hi All,
I recently bought a Nexus 7 for USB development.  I would like to use the 
USB Host functionality provided by the new Android OS.  I was following the 
USB Host Tutorial at the link: 
http://developer.android.com/guide/topics/connectivity/usb/host.html.

My program is very simple, and here are the relevant parts of the code:

*    private UsbManager manager;
*
* *
*    public void onCreate(Bundle savedInstanceState) {*
*        super.onCreate(savedInstanceState);*
*        setContentView(R.layout.activity_main);*
*        *
*        Log.i(TAG, "in onCreate()");*
*        manager = (UsbManager) getSystemService(Context.USB_SERVICE);*
*        if(manager==null) {*
*        Log.i(TAG, "USB Manager is NULL");*
*        }*
*        else {*
*        Log.i(TAG, "USB Manager = " + manager);*
*        }*
*    }*
*    *
*    public void enumerateUSBDevices() {*
*    HashMap<String, UsbDevice> deviceList = manager.getDeviceList();*
*    Collection<UsbDevice> deviceCollection = deviceList.values();*
*    Iterator<UsbDevice> deviceIterator = deviceCollection.iterator();*
*    Log.i(TAG, "Number of connected USB Devices = " + 
deviceCollection.size());*
*    while(deviceIterator.hasNext()){*
*        UsbDevice device = deviceIterator.next();*
*        Log.i(TAG, device.getDeviceName());*
*    }*
*    }*


When the enumerateUSBDevices function is called, it reports that the number 
of connected USB Devices = 0.  I am using a USB OTG cable, and I know that 
the Nexus 7 is powering the connected USB Device because I plugged in a USB 
Mouse, and it works properly.  I also plugged in another Android phone, and 
the Nexus 7 was confirmed to be powering the device.  However, in both of 
these instances, the Android program says that there are no USB devices 
connected.  I am unsure what is going wrong in my code.  In my Android 
manifest, I have the following line:

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

My manifest does not have any intent filters associated with any USB 
devices.  My understanding based on reading the tutorials is that the 
intent filters need to be in the Manifest only if you want the APP to be 
notified when the USB device is connected after the App is running?

Can anybody shed light into what I may be doing wrong?  Do I need to root 
my device?

Thanks,
Kiran

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to