Smart Lock SDK

Last Updated on : 2024-11-18 11:33:15download

Smart Lock SDK for Android encapsulates the APIs to communicate with smart locks over Bluetooth and Wi-Fi and accelerates lock app development. The SDK supports the following features:

  • Lock user system: manage lock users and associated passwords
  • Unlocking with passwords: get dynamic passwords and manage temporary passwords
  • Lock usage records: unlocking records, doorbell records, and alerts

The SDK is currently available in preview, being continuously optimized. If you have any problems or suggestions about the SDK, submit a ticket to request technical support.

Before you start

The Smart Lock SDK serves your development as an extension of Smart Life App SDK. For more information, see Preparation.

Integrate with the SDK

Add a dependency

Add the following dependency to the file build.gradle of module:

dependencies {
    ...
   implementation 'com.tuya.smart:tuyasmart-lock-sdk:1.2.5'
}

Add permissions

To scan and connect to Bluetooth devices, add the following permissions to AndroidManifest.xml. These permissions do not apply to non-Bluetooth devices.

<!-- Required. Allows applications to connect to paired bluetooth devices.  -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<!-- Required. Allows applications to discover and pair bluetooth devices.  -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Required.  Allows an app to scan bluetooth device.  -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required.  Allows an app to scan bluetooth device.  -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!--  Allows an app to use bluetooth low energy feature  -->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />

For more information about dynamic permissions, see Android’s document Request app permissions.