Some device types (like a usb mouse) apparently are handled on system level and are not exposed to apps. Since different Android devices support different usb devices (e.g. usb storage, usb speakers, ...), some types of usb devices may be visible on some android devices only...
Am Donnerstag, 19. September 2013 21:55:19 UTC+2 schrieb eli: > > <http://stackoverflow.com/questions/18900666/android-usb-problems#> > ** > > I have a tablet, an OTG cable and a barcode reader. I know this works > because when I start the Google app I can scan barcodes and see them on the > screen. > > I created a very simple application that starts the USB manager and checks > how many devices are attached. > > When I have a memory flash stick in the OTG cable the program shows 1. > (correct) > > When I have a mouse in the OTG cable it shows 0. (why) > > Interesting observation. When I connect the mouse to the OTG cable it > works fine. I use it to click on the button to ask the usbManager how many > devices are attached and the response is 0. > > When I attach a barcode reader to the OTG cable, the application goes > through onDestroy() and then shows 0. (Why does this happen) > > Basics of my program developed using Eclipse: > > In onCreate() I have: > > usbManager = (UsbManager)getSystemService(Context.USB_SERVICE); > > > > In onClick() I have (there is a button on the screen): > > Map<String, UsbDevice> usbDeviceList = > sbManager.getDeviceList();Toast.makeText(this, String.format("Number of > devices = %d", usbDeviceList.size()), Toast.LENGTH_SHORT).show(); > > -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.