From helping you log your meals with MyFitnessPal to getting a holistic view of your health with Withings, apps and devices are a source for many kinds of useful health and fitness data. As Android developers, connecting and sharing this data between apps can help you provide more meaningful experiences and insights for your users. However, much of this information is spread across multiple experiences and different devices, making it difficult to bring together. Moreover, there are no centralized privacy controls for Android users.
Introducing Health Connect
This is why we’ve created Health Connect, a platform and API for Android app developers. With user permission, developers can use a single set of APIs to securely access and share health and fitness data across Android devices.
We're building this new unified platform in collaboration with Samsung to simplify connectivity between apps. We appreciate Samsung’s collaboration as we roll out Health Connect to foster richer app experiences while also providing centralized privacy controls for users.
We've been working with developers including MyFitnessPal, Leap Fitness and Withings as part of an early access program. In addition, Samsung Health, Google Fit and Fitbit are adopting Health Connect. Starting today, all developers can get access to Health Connect's common set of APIs for Android via Android Jetpack.
Health Connect fits in with Google’s wider efforts to help billions of people be healthier, using our platforms and technology to connect and bring more meaning to health information.
How does Health Connect work?
How Health Connect Works
Health Connect supports many common health and fitness data types and categories, including: activity, sleep, nutrition, body measurements and vitals like heart rate and blood pressure.
With user permission, developers can securely read from and write data to Health Connect, using standardized schema and API behavior. Users will have full control over their privacy settings, with granular controls to see which apps are requesting access to data at any given time. The data in Health Connect is all on-device and encrypted. Users will have the ability to shut off access or delete data they don’t want on their device, and the option to prioritize one data source over another when using multiple apps.
Getting started
It’s easy to get started with Health Connect. Health Connect’s single set of APIs makes it simple to manage permissions and read and write data. Here’s an example of how you can request permissions and then write some data.
First, build a set of the permissions you plan to request read or write access to. In this example we are reading and writing steps and heart rate.
private val permissions =
setOf(
Permission.createReadPermission(Steps::class),
Permission.createWritePermission(Steps::class),
Permission.createReadPermission(HeartRate::class),
Permission.createWritePermission(HeartRate::class),
)
// then, create a permissions request for this set of permissions
Then, launch the permissions request, which will bring the user to the Health Connect permissions UI to grant permissions.
Once the user grants permission, you are ready to read and write data. Here’s an example of how to write steps data over a period of time. Include the total number of steps, start and end time, and timezone information, and then insert the data into Health Connect.
private suspend fun writeSomeData(client: HealthConnectClient) {
val records = mutableListOf<Record>()
records.add(
Steps(
count = 888,
startTime = START_TIME,
endTime = END_TIME,
startZoneOffset = null,
endZoneOffset = null,
)
)
// add additional records as needed
}
Learn more
Health Connect is now available to developers:
- Check out the Documentation
- Download the SDK from Android Jetpack
- Review the revised privacy & security policy
- Find code samples on our Github page
- Sign up for the open beta via Google Play
Watch the technical session below:
https://android-developers.googleblog.com/search/label/Health%20Connect%20API
'Mobile > Android' 카테고리의 다른 글
[AOS] Health Connect - 헬스 커넥트를 통해 건강/피트니스 앱 통합을 간소화한 Signos (0) | 2023.02.22 |
---|---|
[AOS] Health Connect 적용하기 - Leading Health and Fitness Apps Roll Out Health Connect Integrations (0) | 2023.02.15 |
[AOS] Android SDK 플랫폼 출시 노트 - API 레벨 (0) | 2023.01.15 |
[Android] Android 12 - startScanner java.lang.SecurityException (0) | 2022.02.15 |
[Android] 개발자 정책 변경 (6/16일까지 변경 필요) (0) | 2020.05.19 |