Friday, June 21, 2024
HomeMobileStage up your apps with the most recent options from Android Well...

Stage up your apps with the most recent options from Android Well being



Posted by Breana Tate – Developer Relations Engineer, Android Well being

Android Well being’s mission is to allow billions of Android customers to be more healthy by entry, storage, and management of their well being, health, and security knowledge. To additional this mission, we provide two main APIs for builders, Well being Join and Well being Providers on Put on OS, that are each utilized by a rising variety of apps on Android and Put on OS.

AI capabilities unlock wonderful and distinctive use instances, however to be able to ship probably the most worth to your customers on the proper time, you want a robust basis of knowledge. Our updates this yr give attention to serving to you construct up this knowledge basis, with assist for extra knowledge varieties, new methods to entry knowledge, and extra strategies of getting well timed knowledge updates while you want them.

Adjustments to the Google Match APIs

We just lately shared that Google Match developer companies might be transitioning to grow to be a core a part of the Android Well being platform. As a part of this, the Google Match APIs, together with the REST API, will stay obtainable till June 30, 2025.

Well being Join is the really useful answer for storing and sharing well being and health knowledge on Android telephones. Starting with Android 14, it’s obtainable by default in Settings. On pre-Android 14 gadgets, it’s obtainable for obtain from the Play Retailer. Well being Join lets your app join with a whole bunch of apps utilizing a single API integration. Up to now, over 500 apps have built-in with Well being Join and have unlocked deeper insights for his or her customers. Try the featured record to see a number of the apps which have built-in.

We’re excited to proceed supporting the Google Match Android Recording API performance by the Recording API on cellular, which permits builders to document steps, and shortly distance and energy, in a power-efficient method. In distinction to the Google Match Android Recording API, the Recording API on cellular doesn’t retailer knowledge within the cloud by default, and doesn’t require Google Signal-In. The API is designed to make migrating from the Match Recording API easy. Regulate d.android.com/health-and-fitness for upcoming documentation.

Upcoming capabilities from Well being Join

Well being Join will quickly add assist for background reads and historical past reads.

Background reads will allow builders to learn knowledge from Well being Join whereas their app is within the background, that means which you can hold knowledge up-to-date with out counting on the person to open your app. This can be a departure from present habits, the place apps can solely learn from Well being Join whereas the app is within the foreground or operating a foreground service.

Historical past reads will give customers the choice to grant apps entry to all historic knowledge in Well being Join, not simply the previous 30 days.

With each background reads and historical past reads, customers are in management. Each capabilities require builders to declare the respective permissions, and customers should approve the permission requests earlier than builders could make use of the information protected by these permissions. Even after granting approval, customers have the choice of revoking entry at any time from inside Well being Join settings.

Each options might be launched later this yr, so keep tuned to discover ways to add assist to your apps!

Updates to Well being Providers on Put on OS

Well being Providers on Put on OS is a set of APIs that makes it easy to create power-efficient well being and health experiences on Put on OS.

In Put on OS 5, we’re introducing 2 new options:

    • New knowledge varieties for operating
    • Assist for debounced targets

New Information Sorts for Working

Beginning with Put on OS 5, Well being Providers will assist new knowledge varieties for operating. These knowledge varieties might help present further insights on operating type and economic system.

The complete record of latest superior operating metrics is:

    • Floor Contact Time
    • Stride Size
    • Vertical Oscillation
    • Vertical Ratio

As with all knowledge varieties supported by Well being Providers on Put on OS, you’ll want to verify train capabilities in order that your app solely makes use of metrics which can be supported on the gadgets operating your app, making a smoother expertise for customers. That is particularly necessary for Put on OS, as there’s a robust ecosystem of gadgets for customers to select from, they usually don’t at all times assist the identical metrics.

// Checking if the machine helps the RUNNING train and confirming the 
// knowledge varieties which can be supported.
droop enjoyable getExerciseCapabilities(): ExerciseTypeCapabilities? {
   val capabilities = exerciseClient.getCapabilitiesAsync().await()
   return if (ExerciseType.RUNNING in capabilities.supportedExerciseTypes) {
       capabilities.getExerciseTypeCapabilities(ExerciseType.RUNNING)
   } else {
       null
   }
}


. . .


// Checking whether or not the information varieties that we need to use are supported by
// the RUNNING train on this machine.
val dataTypes = setOf(
   DataType.HEART_RATE_BPM_STATS,
   DataType.CALORIES_TOTAL,
   DataType.DISTANCE_TOTAL,
   DataType.GROUND_CONTACT_TIME,
   DataType.VERTICAL_OSCILLATION
).intersect(capabilities.supportedDataTypes)

Checking train capabilities with Well being Providers on Put on OS

To make this simple, we’ve launched a sensor panel, obtainable beginning in Android Studio Koala Function Drop, which is at the moment in Canary. You need to use the panel to check your app throughout a wide range of machine capabilities, experimenting with conditions the place metrics like coronary heart price or distance aren’t obtainable.

The Health Services sensor panel

The Well being Providers sensor panel

Assist for debounced targets

Second, Well being Providers on Put on OS will quickly assist debounced targets for instantaneous metrics. These embrace metrics like coronary heart price, distance, and pace, for which customers need to keep a specified threshold or vary all through an train.

Debounced targets stop the identical occasion from being emitted a number of occasions—each time the situation is true—over a short while interval. As an alternative, occasions are emitted provided that the edge has been repeatedly exceeded for a (configurable) variety of seconds. You can too stop occasions from being emitted instantly after purpose registration.

This assist comes from two new methods to higher time purpose alerts for instantaneous metrics: period at threshold and preliminary delay:

    • Period at threshold is the quantity of uninterrupted time the person must cross the required threshold earlier than Well being Providers sends an alert occasion.
    • Preliminary delay is the period of time that should go, since purpose registration, earlier than your app is notified.

Collectively, these options scale back the variety of false positives and repeated alerts surfaced to customers in case your app lets customers set health targets or targets.

Period at Threshold

Preliminary Delay

Definition

The quantity of uninterrupted time the person must cross the required threshold earlier than Well being Providers will ship an alert occasion.

The period of time that should go since purpose registration, earlier than your app is notified.

Goal

Forestall false positives.

Forestall repeatedly notifying the person.

Counter begins

As quickly as person crosses the required threshold

As quickly because the monitoring request is ready

The variations between Period at Threshold and Preliminary Delay

A typical use case for debounced targets includes coronary heart price zones. Coronary heart price repeatedly fluctuates all through an train, particularly throughout cardio-intensive actions. With out assist for debouncing, an app may get many alerts in a brief time frame, resembling every time the person’s coronary heart price dips above or beneath the goal vary.

By introducing an preliminary delay, you possibly can inform Well being Providers to ship a purpose alert solely after a specified time interval has handed–consider this like an adjustment interval. And by introducing a period at threshold, you possibly can take this customization additional, by specifying the period of time that should go in (or out) of the required threshold for the purpose to be activated. In apply, this might be like ready for the person to be out of their goal coronary heart price vary for 15 seconds earlier than your app lets them know to extend or lower their depth.

Try the technical session, “Constructing Adaptable Experiences with Android Well being” to see this in motion!

Your app’s coaching companion

The Well being & Health Developer Middle is your one-stop-shop for constructing well being & health apps on Android! Go to the location for documentation, design inspiration, case research, and extra to discover ways to construct apps on cellular and Put on OS.

We’re excited to see the Well being and Health experiences you proceed to construct on Android!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments