Integrating Sahha

Android Integration

Learn how to integrate the Sahha SDK into your Android project


Step 1) Add Jitpack

Add the Jitpack repository to your project's Settings.gradle.

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}

Step 2) Add Implementation

Add the Sahha SDK implementation to your project's dependencies in Build.gradle.

dependencies {
...
implementation 'com.github.sahha-ai:sahha-android:+'
...
}

Step 3) Import Module

Import the Sahha module into any files inside your project that use the SDK.

import sdk.sahha.android.source.*

Step 4) Add Sensor Permissions

In order to access your user's device sensors, you will need to include the correct uses-permission values in your project's AndroidManifest.xml.

Step 1) Find the project’s AndroidManifest.xml file. This is located in the project’s app/src/main folder.

Android Manifest

Step 2) Within the file, declare the permissions between the manifest and application code.

Android Manifest

Step 3) Here is an example declaring Heart and Activity permissions. Make sure to save the file!

Android Manifest


Optional Sensor Values

Each sensor has a set of associated user-permission values. You can see the full list below.

<!-- AndroidManifest.xml -->
<!-- Heart -->
<uses-permission android:name="android.permission.health.READ_HEART_RATE" />
<uses-permission android:name="android.permission.health.READ_HEART_RATE_VARIABILITY" />
<uses-permission android:name="android.permission.health.READ_RESTING_HEART_RATE" />
<!-- Blood -->
<uses-permission android:name="android.permission.health.READ_BLOOD_GLUCOSE" />
<uses-permission android:name="android.permission.health.READ_BLOOD_PRESSURE" />
<!-- Sleep -->
<uses-permission android:name="android.permission.health.READ_SLEEP" />
<!-- Activity -->
<uses-permission android:name="android.permission.health.READ_STEPS" />
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED" />
<!-- Oxygen -->
<uses-permission android:name="android.permission.health.READ_VO2_MAX" />
<uses-permission android:name="android.permission.health.READ_OXYGEN_SATURATION" />
<uses-permission android:name="android.permission.health.READ_RESPIRATORY_RATE" />
<!-- Energy -->
<uses-permission android:name="android.permission.health.READ_BASAL_METABOLIC_RATE" />
<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED" />
<uses-permission android:name="android.permission.health.READ_TOTAL_CALORIES_BURNED" />
<!-- Body -->
<uses-permission android:name="android.permission.health.READ_BODY_FAT" />
<uses-permission android:name="android.permission.health.READ_BODY_WATER_MASS" />
<uses-permission android:name="android.permission.health.READ_LEAN_BODY_MASS" />
<uses-permission android:name="android.permission.health.READ_BONE_MASS" />
<uses-permission android:name="android.permission.health.READ_HEIGHT" />
<uses-permission android:name="android.permission.health.READ_WEIGHT" />
<!-- Temperature -->
<uses-permission android:name="android.permission.health.READ_BODY_TEMPERATURE" />
<uses-permission android:name="android.permission.health.READ_BASAL_BODY_TEMPERATURE" />

Device Sensor

Please note SahhaSensor.device does not require any AndroidManifest.xml permission declarations.


Choose your Sensors

Add each set of uses-permission values for each required sensor to your project's AndroidManifest.xml.

Choosing Sensor Permissions

For example, if your project requires the Heart and Sleep sensors, then included the following uses-permission values:

"READ_HEART_RATE"

"READ_HEART_RATE_VARIABILITY"

"READ_RESTING_HEART_RATE"`

"READ_SLEEP"

<!-- AndroidManifest.xml -->
<manifest ... >
<!-- Heart -->
<uses-permission android:name="android.permission.health.READ_HEART_RATE" />
<uses-permission android:name="android.permission.health.READ_HEART_RATE_VARIABILITY" />
<uses-permission android:name="android.permission.health.READ_RESTING_HEART_RATE" />
<!-- Sleep -->
<uses-permission android:name="android.permission.health.READ_SLEEP" />
<application ... >
...
<application ... />
<manifest ... />

Configure your Sensors

Configuring Sensors

After including the uses-permission values for each required sensor in your AndroidManifest.xml, you will also need to configure the same sensor values via the Sahha.configure method.

View the SDK Configure documentation .

If the values do not match, you are likely to receive build errors and risk your app being rejected on the Google Play Store!