Getting started: Android configuration
Prepare your project for Samsung Health.
Android configuration
In your build.gradle (app) set your min and target sdk version like below:
minSdk 26
targetSdk 35
Obfuscation
If you are using obfuscation consider the following:
In the app folder create a proguard-rules.pro file and add the following:
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
Finally, in your build.gradle (app) add the proguard-rules.pro
from previous step:
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
In your gradle.properties (Project level) add the following to disable R8 full mode:
android.enableR8.fullMode=false
If you want to enable full mode add the following rules to proguard-rules.pro:
# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.cor outines.Continuation
Request data access
During development, you can access Samsung Health data by enabling developer mode.
To have data access in the production environment, you must submit the Samsung's Partnership Request Form.
Please submit partner request before your app distribution. Your app's package name and signature (SHA-256) will be registered in the Samsung Health's system after an approval.
Ensure that the correct app signature and package name is registered. If your published app signature differs from what you have provided, your app will not have access to Samsung's data.
You will see a section like this, select only the data types under the "Read" section:
This SDK uses the following data types, however you don't need to declare all of them if you don't use it.
- ACTIVITY_SUMMARY
- BLOOD_GLUCOSE
- BLOOD_OXYGEN
- BLOOD_PRESSURE
- BODY_COMPOSITION
- EXERCISE
- EXERCISE_LOCATION
- FLOORS_CLIMBED
- HEART_RATE
- NUTRITION
- SLEEP
- STEPS
- WATER_INTAKE
If you exclude a data type of the previous list DO NOT use it in the permissions functions (check/request).
Secure storage (optional)
This SDK saves sensitive information like current logged user in a password protected storage, you can specify a file name (without extension) and the password used to access it with two meta-data tags in your manifest:
This configuration is completely optional if you don't provide the two following tags the SDK will use a default file name and auto-generate a new password every time your app is installed or it's data is deleted.
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<!--
PLEASE NOTE THAT BOTH TAGS ARE REQUIRED
IF YOU EVER LOSE THE PASSWORD THE SDK WILL BECOME UNABLE TO PERFORM ITS FUNCTIONS
YOU CAN CHANGE THE NAME OF THE STORAGE TO FIX IT, BUT ALL PREVIOUS DATA WILL BE LOST.
-->
<meta-data
android:name="io.tryrook.samsung.security.storage.FILE_NAME"
android:value="secure_storage"/>
<meta-data
android:name="io.tryrook.samsung.security.storage.PASSWORD"
android:value="my_super_secret_password"/>
</application>
</manifest>