Android – USB Host Mode – device access permission granted but not remembered

androidhostusb

I have a USB Host Mode application that works perfectly. I plug in the device, Android pops up the Allow the app APPNAME to access the USB device? permission request window, I check the Use by default for this USB device tick box and tap OK, then up comes my app and it communicates with the USB device perfectly.

BUT…

Then I unplug the device and plug it back in. Android pops up the Allow the app APPNAME to access the USB device? dialog again. WTH? I've already told Android to do this by default, so why is it asking me again?

This happens both with Icecream Sandwich 4.0.3 and Jellybean 4.1.

Ideally I want Android to remember I've granted permission for this particular USB device even after I've rebooted the Android device.

So why isn't Android remembering that I've granted permission?

Best Answer

This is a dup of USB device access pop-up supression?. Basically the answer is to use an intent-filter on USB_DEVICE_ATTACHED and steer clear of the RequestPermission USB Host Mode API call.

Related Topic