Skip to content
On this page

SDK Integration

The Android SDK is provided as an Android archive library file named bnhsdk.aar. Follow the steps below to integrate the SDK into your application.

1. Add the SDK to your Project

The following screenshot is taken from the SDK Sample App.

img

2. Update your Application build.gradle File

Add the following lines to your application build.gradle dependencies section:

dependencies {
    ...
    implementation fileTree(include: ['*.jar'], dir: 'libs') 
    implementation files('libs/bnhsdk.aar') 
}

Note

The instructions above are based on the Android instructions for adding an .aar dependency to your app.

3. Add the SDK Dependencies to the Gradle (Not Required if Using Only Camera Sessions)

The following dependencies are required when creating Polar based sessions. More specifically, when using the following API calls:

Kotlin
PolarSessionBuilder.build(licenseDetails)
PPGDeviceScannerFactory.create(context, PPGDeviceType.POLAR, this)
Java
PolarSessionBuilder.build(licenseDetails)
PPGDeviceScannerFactory.create(context, PPGDeviceType.POLAR, this)

1. Add the JitPack repository to your repositories settings

...
    repositories {
        ...
        maven { url 'https://jitpack.io' }
        ...
    }
}

2. Add the SDK's dependencies

dependencies {
    implementation 'com.github.polarofficial:polar-ble-sdk:5.1.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.1.6'
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
}

4. Add the Necessary Permissions

The SDK requires specific permissions to function properly. These permissions should be added to your application's AndroidManifest.xml file, depending on your use case.

Camera Permissions (Face/Finger Sessions)

xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-feature android:name="android.hardware.camera.front" android:required="true"/>

Bluetooth Permissions (PPG Devices Sessions)

xml
<!-- The SDK needs Bluetooth scan permission to search for BLE devices. 
Binah SDK doesn't use the scan to decide the location so "neverForLocation" permission 
flag can be used.-->
<uses-permission
    android:name="android.permission.BLUETOOTH_SCAN"
    android:usesPermissionFlags="neverForLocation"
    tools:targetApi="s" />
    
<!-- Binah SDK needs Bluetooth connect permission to connect for found BLE devices.-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- Allows Binah SDK to connect to paired bluetooth devices. Legacy Bluetooth permission,
which is needed on devices with API 30 (Android Q) or older. -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />

<!-- Allows Binah SDK to discover and pair bluetooth devices. Legacy Bluetooth permission,
which is needed on devices with API 30 (Android Q) or older. -->
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />

<!-- Binah SDK needs the fine location permission to get results for Bluetooth scan. Request
fine location permission on devices with API 30 (Android Q). Note, if your application 
needs location for other purposes than bluetooth then remove android:maxSdkVersion="30"-->
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30" />

<!-- The coarse location permission is needed, if fine location permission is requested. Request
coarse location permission on devices with API 30 (Android Q). Note, if your application 
needs location for other purposes than bluetooth then remove android:maxSdkVersion="30" -->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30" />

5. Build Android App Bundle (.aab)

When building the app as Android App Bundle (.aab extension), add the useLegacyPackaging flag to build.gradle file, under the android section as the following example:

android {   
    packagingOptions {
        jniLibs {
            useLegacyPackaging = true
        }
    }
}