Skip to content

2.18.0.1 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 https://developer.android.com/guide/topics/connectivity/bluetooth/permissions!

Migration

AndroidManifest

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"
        android:maxSdkVersion="30"/>

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="30"/>

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

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

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

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.