javaandroidruntime-permissions

Permissions in Android application


I am developing an app to play with a remote controlled car I built. The car is controlled via Bluetooth SPP.

In order to use Bluetooth, I request the BLUETOOTH_CONNECT runtime permission.

Tested in an android 14 (API 34) emulated device the app works fine, the permission popup shows up and I can either grant or deny the permission.

But when I try to run my app on my Android 10 Samsung Galaxy S9, the permission pop-up does not show and the app behaves like the permission has been denied. The permission does not even appear in the settings, so I cannot grant it via the settings.

Is there something I am missing? adb logcat shows no error, neither on Android 14 nor on Android 10 devices.

As usual, the Android developer documentation is no help.

I do have experience in Java development, but I am a newcomer in Android development. I wish to avoid switching to Kotlin. I develop my app using LibGDX 1.12.1.


Solution

  • As usual, the Android developer documentation is no help

    The documentation shows that the BLUETOOTH_CONNECT permission is new to API Level 31, and that API Level 31 is for Android 12.

    So, you cannot request that permission on Android 10.

    The documentation even has an entire page dedicated to Bluetooth permissions, including a section for Android 11 and older and a section for Android 12 and higher.

    For your Android 10 device, you need the BLUETOOTH and ACCESS_FINE_LOCATION permissions in your manifest, and you need to request ACCESS_FINE_LOCATION at runtime. You can use the android:maxSdkVersion attribute on the <uses-permission> manifest element so that you are not requesting those permissions on newer devices.