简体   繁体   中英

Unable to Connect to BLE device in Android 12+

I am trying to connect to BLE device in Android 12 using connectGatt method but It's not connecting.

Below Android 11 it is working fine.

  1. I have added all the required permissions for Android 12 Manifest.permission.BLUETOOTH_SCAN and Manifest.permission.BLUETOOTH_CONNECT .
  2. I have tried all the transports AUTO, BLE and BR/EDR.
  3. I am also allowing runtime permissions for Bluetooth.

The required device MAC address is found in discover callback. But, When I try to connect It's not receiving any callback and after few seconds It's sending me DISCONNECT BroadcastReceiver.

Many beacon devices still require location service for scanning.

That's why location service still requires in Android 12, giving permission to location android.permission.ACCESS_FINE_LOCATION and android.permission.ACCESS_COARSE_LOCATION also allows android.permission.BLUETOOTH_SCAN in AndroidManifest, and explicitly grant these permissions at runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM