So I have an Android app that requires an USB connection to an Arduino to work. After it's connected, or if I start the app with the Arduino connected via USB, everything works fine, the data transmition is clean.
My problem is whenever I connect the USB after the app has started. It seems to quickly fire multiple requests and my code that runs whenever something is connected via USB (to detect if it is an Arduino and do its first configurations) end up also running multiple times.
This is the trace whenever I connect the Arduino via USB:
The D/UsbRequestJNI: init
runs from 4-8 times, resulting in my code (D/ARDUINO: Arduino connected!
) also running every time.
I've read that sometimes the USB connection can be unstable in some devices. I'm running it on a Android 7.1.2 Philco PTB7PAP tablet. Does that relate/is that normal? What can I do to avoid it, if that is even possible?