My react native app (running on Android) is restarting whenever Bluetooth headphones are connected or disconnected. Why is this happening and how can I prevent it?
I'd expect the app to remain open when Bluetooth headphones are connected or disconnected, but instead the app restarts (the 'activity is recreated' in Android lingo).
I've tried altering the manifest by adding this line, but it didn't fix the issue:
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
A bit overkill, but I tried adding even more BT related permissions, which still didn't fix the issue:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
What am I missing?
Environment:
- React-native: 0.66.2
- Android OS: 12
- Device: Pixel 4