The permission should only be asked once.
I apologize for not being able to explain well what I want to achieve, but I will try.
I just want one thing - to make an app not automatically appear in the foreground when a known USB device is connected.
My app behaves correctly, it remembers all permissions (it only asks permission once) and the USB device works fine.
A user sets something in the app and the USB device starts transmitting and receiving data.
The user starts another application and the USB device continues to run in the background.
But when there is a momentary failure of the USB device (for example, a shock causing a temporary lack of connection) and when the USB resumes,
the background application goes to the foreground. This is standard android behaviour for a known PID and VID of a USB device - I think so.
However, I would like to change this behavior so that the application remains in the background. How do I achieve this?