简体   繁体   中英

Android 12 Nearby Devices permission crashes app

Yo, I have an app that connects to Bluetooth devices (we specify the MAC address). It targets API 28 and Compile SDK is 31.

This is all working fine however I just got a Pixel 6 Pro and the app crashes anytime I try to do anything Bluetooth related. The crash says: Need android.permission.BLUETOOTH_CONNECT permission

The app already has this permission in the Manifest. I can fix the crash but I have to go into the app permissions and allow permission for Nearby devices.

Is there something I have to do to get this working without having to explicitly allow the permission? On API 28 preferably too. I tried what was in the Google Dev docs but seems to still crash. I never had to allow this at runtime previously, is this required now on Android 12? Thanks

According to Google developer docs you have to ask for permission at runtime, see this article for reference.

Every time you want to perform an action that may be guarded by a permission, ask the user for permission, even if it was previously granted.

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