1

I connect two USB devices to my Android 3.1 tabled and I try to iterate over all of them and request the permission for each:

UsbManager mManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
...
for (UsbDevice device :  mManager.getDeviceList().values()) {
  mManager.requestPermission(device, mPermissionIntent);
  ...           
}

The issue is that only one permission screen appears instead of two and I suspect requestPermission causing this. Are there any workarounds in Android for that?

Alin
  • 1,176
  • 1
  • 12
  • 15
  • Maybe this question will be able to help you http://stackoverflow.com/questions/13299393/getdevicelist-always-empty – Boardy Jan 14 '13 at 11:54
  • I am able to iterate through the devices, the issue is that only one of them show the permission screen. – Alin Jan 14 '13 at 19:29

1 Answers1

2

My workaround is, if there are multiple permission requests to be issued, issue one at a time. That is, after the receiver has got the response to the first permission request, issue the next request. I tested this workaround last night, and it solved the missing permission screen and missing response problem. I am using Android 4.x.

hwt
  • 36
  • 1
  • how did you implemented that? using java synchronization? – Alin Jan 29 '13 at 09:09
  • 2
    In Activity.onCreate(), I get a list of USB devices and put them in a collection. Then take one USB device from the collection and initiate a permission request. When the receiver receives the outcome of the permission request, it takes another USB device from the collection and initiates yet another permission request. This continues until there is no more USB device left in the collection. – hwt Feb 02 '13 at 07:35