Menu

 

Getting Started

Intro

To integrate Health Connect into your app you need to add a WeFitter plugin into your app. This plugin uses the WeFitter profile of your enduser to send data from Health Connect to WeFitter.

Do you want to know more? Check out the website of Health Connect.

 

Requirements

  •  - Kotlin (see this guide on how to add Kotlin support to your app)
  •  - minSdkVersion 26 (see this link for more information)
  •  - compileSdkVersion 34
  •  - targetSdkVersion 34

 

Approval

To read data from Health Connect in release mode your app needs to be approved by Google. Please read the guide about Plan compliance with privacy policies and fill in the Developer Declaration Form.

The following datatypes can be requested:

  •  - BloodGlucoseRecord
  •  - BloodPressureRecord
  •  - BodyFatRecord
  •  - BodyTemperatureRecord
  •  - CyclingPedalingCadenceRecord
  •  - DistanceRecord
  •  - ExerciseSessionRecord
  •  - HeartRateRecord
  •  - HeightRecord
  •  - OxygenSaturationRecord
  •  - PowerRecord
  •  - SpeedRecord
  •  - StepsCadenceRecord
  •  - StepsRecord
  •  - TotalCaloriesBurnedRecord
  •  - WeightRecord

 

Setup

It doesn't matter if you are building a native app or if you are using a framework, you will have to add an activity that acts as an permission rationale.

This activity will be shown when the user navigates to your app in Health Connect settings. Without this activity you will not see a permission modal in your app. You can customize the layout or for example use Jetpack Compose instead.

Add the following code to your app:

Show code example
Hide code example

AndroidManifest.xml

<activity
    android:name=".PermissionsRationaleActivity"
    android:exported="true">
  <intent-filter>
    <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
  </intent-filter>
</activity>

Show code example
Hide code example

PermissionsRationaleActivity.kt

package com.example.app

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class PermissionsRationaleActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_permissions_rationale)
    }
}

Show code example
Hide code example

activity_permissions_rationale.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This app would like to have access to your data" />

</LinearLayout>

 

Next step

To continue implementing please see the instructions depending on how you are building your app:

    - Native
    - Cordova
    - React Native

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.