androidAndroid

The Thryve iOS SDK is the fastest way to implement Thryve's product into your Android application and is required to allow users to connect Health Connect and Samsung Health as a data source. The Thryve iOS SDK is available via the Maven repository and frameworks.

Integrate using Thryve Repository Dependencies

Thryve provides a private, protected repository supporting the Maven repository format to retrieve the Thryve SDK build artifacts. To configure a Gradle project to resolve dependencies declared in build.gradle file, the Thryve repository has to be declared as shown in the root and app build.gradle files.

The Root build.gradle file

allprojects {
    repositories {
        ... 
        maven {         
            url = uri("https://nexus.external.thryve.de/repository/releases/")
            credentials {
                    username = thryveUsername
                    password = thryvePassword
            }
        }
        ...
    }
}

Your username and password are provided in onboarding when signing up with Thryve. It is recommended to store credentials in your project’s local.properties or the user-global Gradle properties gradle.properties

The App build.gradle file

Add dependencies to the app build.gradle after adding the repository

circle-info

You must use api instead of implementation to make the Thryve SDK and it's modules work correctly

circle-info

Note the change in name of the package. The versions preceding 5.0.0 used com.thryve.connector . Use the appropriate package when upgrading to or downgrading from 5.x

Integrate using Thryve .aar Libraries

The Thryve Android SDK module is available as a standard Android Archive (aar). You can download the framework files here:

Integrating AAR Libraries into Your Application

  1. Add AAR File:

    1. Place the .aar file in a project directory, such as libs.

  2. Update build.gradle:

    • Add implementation files('libs/.aar').

  3. Enable Kotlin Support:

  4. Add Android Support Libraries:

    • Integrate the Android AppCompat-Library.

  5. Set Java Compatibility:

    • Ensure target and source compatibility for Java 1.8.

  6. Set Kotlin JVM Target:

    • Use Kotlin JVM target version 1.8.

Ensure you include the necessary dependencies for the Thryve SDK and verify that they are all compatible versions.

Configure dependency versions

Keeping your dependency versions aligned with the supported versions of the Thryve Android SDK is crucial for ensuring compatibility and maintaining the stability of your application.

Outdated or mismatched versions can lead to integration issues, such as runtime errors or unexpected behavior, which may hinder app performance and user experience.

circle-info

When updating Thryve SDK versions, always refer to the release changelog for documented dependency version updates.

Health connect configuration

To integrate Health Connect with your Android app, utilize the ThryveHealthConnect module from the Thryve Android SDK. This module enables users to connect with Health Connect on their smartphones and allows your app to retrieve evaluated and aggregated data from various sources linked to Health Connect. You can integrate it by using Thryve Maven Repository Dependency or AAR Libraries and updating your app's build.gradle file accordingly.

circle-exclamation

Declare Health Connect permissions

To utilize Health Connect, your application must declare all necessary permissions and provide a privacy policy activity for handling the ACTION_SHOW_PERMISSIONS_RATIONALE intent within the AndroidManifest. Pay attention to the differences in declarations for Android 14 versus older versions.

Ensure that the declared policies align with the data types set in ThryveHealthConnectConfig. Also, remember to declare permissions for background sync and health data history when enabling these features.

Samsung Health configuration

To integrate Samsung Health into your Android application, add the ThryveSamsungHealth module from Thryve's SDK. This enables your users to connect seamlessly with Samsung Health and trigger background processes to fetch the latest health data automatically. You can achieve this by utilizing either the Thryve Maven Repository Dependency or AAR Libraries, along with necessary updates to your app's build.gradle.

circle-info

To access data from Samsung Health using the ThryveSamsungHealth module, register your application with the Samsung Partner App Program. The Thryve SDK includes all necessary Samsung SDKs, eliminating the need for additional logic. Ensure your application ID is approved by Samsung for Samsung Health access. For more details, visit the Samsung developer websitearrow-up-right.

circle-check

Configure ProGuard

To suppress warnings from the SHealth library after adding the ThryveSamsungHealth module, include -dontwarn com.samsung.** in your proguard-rules file.

Configure the Android Work Manager

To effectively schedule tasks with the Samsung Health SDK’s synchronization service, the Thryve SDK uses the Android WorkManagerarrow-up-right. To provide a custom implementation and rules for background tasks, implement Configuration.Provider and use WorkManagerInitializer in your Application class. See the Kotlin code example below for guidance. The code snippet changes the minimum logging level for your app, but the implementation can be further customized to your apps needs.

Last updated