0

after migrating the codebase to android 12 target SDK 32, i am trying to get the value of the below settings key

bluetooth_name

but on pixel devices on android 12 i keep getting this crash

Fatal Exception: java.lang.RuntimeException: java.lang.SecurityException: Settings key: <bluetooth_name> is only readable to apps with targetSdkVersion lower than or equal to: 31

from what i've tried so far, there is no extra permission that is needed for this change, also it works completely fine on almost any other device

am i missing something?

Mahmoud Omara
  • 533
  • 6
  • 22

1 Answers1

1

There are new restrictions on Android 12, and Bluetooth requires some extra permissions

However, I don't think that it's a permissions issue -- you simply can't access that setting with Android 12 or higher. You'll need to use the BluetoothAdapter class to get the info you need:

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
String name = adapter.getName()
user496854
  • 6,461
  • 10
  • 47
  • 84