I have an Android App which will interact with an USB device, in the Android developer official documentation for Obtaining permission to communicate with a device it says:
Note: If your application uses an intent filter to discover USB devices as they're connected, it automatically receives permission if the user allows your application to handle the intent. If not, you must request permission explicitly in your application before connecting to the device.
The Intent Filter is to be declared in the AndroidManifest.xml and using a resource file which will include the vendor-id and product-id.
If i plug my device nothing happens, even with the declared Intent.
So i have to use the method mentioned in the same official documentation which involves explicitly asking for permission.
This works and i can communicate with the device, but it happens that the user has to give the permission each time the app is started, or the device reconnected. In the end this will present a message to the user asking for confirmation each time the device is plugged and the application started, and giving the same permission each time is not desirable.
So if the "... automatically receives permission ..." part is not working.
How do i make the intent filter to work?
What am i missing?
Do i have any other alternatives?
This question: Android USB Permissions Dialog never appears had the opposite problem, but the solution won't work for me.
Making the app a System app and bypassing permissions won't work for me either as mentioned here: USB open accessory permissions through a service in android
Any help is greatly appreciated