this is not the answer to your challenge. And I hope that after 3 years my message will be seen.
Regarding your application, it seems that you have the problem that you want your application to be closed by swiping the application. And this is the opposite for us. We have bluetooth app. And when the program is swiped, Everything breaks, and we don't want that to happen, Like this is the case with you. And I want you to help me to make the app not close when I swipe to connect bluetooth. What have you done that the bluetooth connection does not close?
Please contact me here or on my email([email protected]). I'm really mad about the bluetooth running in the background thing.