I have an android application that connects to a USB device using an OTG connection. When plugging in the device, it shows a popup where you can select allow and a checkbox where you can remember this decision. I encountered an issue where it would not remember permissions, as explained in this topic:
USB device access pop-up supression?
The solution given in the topic fixed the issue perfectly for my Moto G with android 4.4.4 installed. As a side effect, whenever the permissions are remembered, it launches the application whenever its not open and the device is attached which is cool!
However when I try the same thing on my Sony Xperia Z1 Compact, with android 5.0.2, it does not remember my preference, nor does the application launch automatically and the dialogue keeps popping up every time permissions are requested by the app. So it seems like the remember check-box does not work!
The activity in my manifest:
<activity
android:name="--removed--"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:label="@string/titlebar_text" >
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/config" />
</activity>
Config.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-device vendor-id="--hidden--" product-id="--hidden--" />
</resources>
So to be clear; this works as expected on my 4.4.4 phone, but not on my 5.0.2 phone. To me this seems to be a android 5 related issue, where permissions may work a bit differently. Is this fixable in my manifest somehow?