Skip to content and Later

Android SDK version 31

The Tapkey Mobile SDK now target Android SDK 31.

For Android apps targeting API Level 31 the permission behavior for scanning and connecting to Bluetooth devices has changed.

Different permissions are required depending on the device's Android version:

  • Android 12 (API Level 31) and later

    • android.permission.BLUETOOTH_CONNECT
    • android.permission.BLUETOOTH_SCAN
  • Android 10 (API Level 29) - Android 11 (API Level 30)

    • android.permission.BLUETOOTH_ADMIN
    • android.permission.BLUETOOTH
    • android.permission.ACCESS_FINE_LOCATION
  • Android 6 (API Level 23) - Android 9 (API Level 28)

    • android.permission.BLUETOOTH_ADMIN
    • android.permission.BLUETOOTH
    • android.permission.ACCESS_COARSE_LOCATION

For more details see!



Update AndroidManifst.xml to declare the required permissions for the different Android API levels. The following declaration works with the Tapkey Mobile SDK for Android.

<manifest  >
        <uses-permission android:name="android.permission.BLUETOOTH"

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"

    <uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"
    <uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"
        android:maxSdkVersion="30" />

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"

    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
        tools:targetApi="31" />

Tapkey does not use Bluetooth to determine the user's location, so android:usesPermissionFlags="neverForLocation" can be set for the android.permission.BLUETOOTH_SCAN permission. Please check, whether this is in line with your app's usage of Bluetooth. If not, the neverForLocation flag mustn't be used and the android.permission.ACCESS_FINE_LOCATION permission has to be requested as well.

Request permissions

Ensure to check and request for these permissions before calling BleLockScanner#startForegroundScan() or BleLockCommunicator#executeCommandAsync(...) otherwise no scan result will be returned or an exception might be raised. This can be be done (e.g.) by calling ContextCompat.checkSelfPermission(...). Find more information in the Android developer documentation.