Android library for integrating WeFitter and Samsung Health into your app


Add wefitter-shealth-2.0.1.aar and samsung-health-data-1.5.0.aar to libs folder which should normally be in app/libs.


Add the following dependencies to your app/build.gradle:

Show code example
Hide code example
dependencies {
    implementation fileTree(dir: "libs", include: ["*.aar"])
    implementation ""
    implementation ""
    implementation ""
    implementation ""
    implementation "com.squareup.okhttp3:okhttp:4.9.2"


Add the following to your MainActivity.kt:

Show code example
Hide code example

import com.wefitter.shealth.WeFitterSHealth
import com.wefitter.shealth.WeFitterSHealthError

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {

        // create instance of WeFitterSHealth
        val weFitterSHealth = WeFitterSHealth(this)

        // create statusListener to receive status changes and errors - optional
        val statusListener = object : WeFitterSHealth.StatusListener {
            override fun onConfigured(configured: Boolean) {
                Log.i(WeFitterSHealth.TAG, "configured: $configured")

                // enable connection if it hasn't already been enabled,
                // or move this for example to a button press or toggle change
                // and then `weFitterSHealth.disconnect()` is also useful.
                if (configured && !weFitterSHealth.isConnected()) {

            override fun onConnected(connected: Boolean) {
                Log.i(WeFitterSHealth.TAG, "connected: $connected")

            override fun onError(error: WeFitterSHealthError) {
                Log.e(WeFitterSHealth.TAG, "error: ${error.reason.message}")

                // `forUser` boolean indicates the error requires user interaction
                // `reason` can be checked to override specific messages
                if (error.reason.forUser) {
                        .setPositiveButton(android.R.string.ok) { _, _ ->
                            // `tryToResolveError` will guide the user on fixing certain errors
                            // for example:
                            // - link to the app store to install or update Samsung Health
                            // - open Samsung Health to accept privacy policy
                            // - open Settings when Samsung Health needs to be enabled
                        .setNegativeButton(android.R.string.cancel, null)

        // customize notification - optional
        val notificationConfig = WeFitterSHealth.NotificationConfig().apply {
            // override fields
            title = "CUSTOM_TITLE"
            text = "CUSTOM_TEXT"
            iconResourceId = R.mipmap.ic_notification // pass custom icon resource id
            channelId = "CUSTOM_CHANNEL_ID"
            channelName = "CUSTOM_CHANNEL_NAME"

        // configure WeFitterSHealth
        // token should be jwt and contain an id corresponding to a WeFitter profile
        // api url should be base without v1.3/ingest/ as the library will append this
        // for example:
        weFitterSHealth.configure("YOUR_TOKEN", "YOUR_API_URL", statusListener, notificationConfig)

Thank you for reaching out!

We will be in touch with you soon. WeFitter team.

You are subscribed!

You will soon receive our newsletter!
WeFitter team.