Git Product home page Git Product logo

health-samples's Introduction

Health Samples Repository

This repository contains a set of individual Android Studio projects to help you get started writing Health-related apps on Android and Wear OS.

The repository is structured by API. Read below for a description of each

Also available is:

However, developers should note that Health Connect should be used in preference to Health Platform for new integrations.

health-samples's People

Contributors

amankhoza avatar breanatate avatar cancan101 avatar cy245 avatar garanj avatar huewu avatar ithinkihaveacat avatar jdkoren avatar josealcerreca avatar jstembridge avatar kokoro-team avatar luizgrp avatar oas004 avatar ozanhonamlioglu avatar renovate[bot] avatar saryongkang avatar yschimke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

health-samples's Issues

Trying to get DataType.STEPS_DAILY -> crash with missing permission

Instead of getting the heart-rate in the PassiveData example i wanted to get the daily step count.
This always crashes:

_FATAL EXCEPTION: main
Process: com.example.passivedata, PID: 6322
java.lang.Exception: Missing permissions
at androidx.health.services.client.impl.internal.StatusCallback.onFailure(StatusCallback.kt:42)
at androidx.health.services.client.impl.internal.IStatusCallback$Stub.onTransact(IStatusCallback.java:80)
at android.os.Binder.execTransactInternal(Binder.java:1159)
at android.os.Binder.execTransact(Binder.java:1123)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@1294ec, Dispatchers.Main.immediate]
_

I'm testing on Samsung Galaxy Watch 4.
I of course also changed the getCapapities call....

Passive Data - App doesn't collect data after restart

After watch reboot, StartupReceiver registers for background data successfully but app doesn't collect any heart rate data until app UI is opened.

I think app needs to initialize main process after reboot too, not just register for heart rate data.

How to reproduce:

  1. install app, open UI
  2. enable passive data & give permission for body sensor
  3. measure heart rate (Samsung Health) > mark result
  4. open Passive Data app - GOOD - value showing in our UI >
  5. restart watch - wait few seconds for StartupReceiver to register for background data
  6. measure heart rate (Samsung Health) >> mark some new result
  7. open Passive data app - ISSUE - app still showing old value - app did not get heart rate measurement
  8. measure heart rate again (Samsung Health) >> mark result
  9. open Passive data app - GOOD - last value is again visible

Can this be improved ?

Min, max, and avg aggregate heart rate and speed stats are always null

I was certain I was doing something wrong (and still could be), but the BPM_AVG value is always null even though I'm certain there's data across the time range. I'm using the following code:

val response = healthConnectClient.aggregate(
    AggregateRequest(
        setOf(HeartRateRecord.BPM_AVG),
        TimeRangeFilter.between(activity.start, activity.end)
    )
)

val avgBpm = response[HeartRateRecord.BPM_AVG]

avgBpm is always null. I checked the sample app and the method readAssociatedSessionData and the "HR stats (bpm)" and "Speed stats (m/s)" sections are only showing "N/A" even though there is plenty of sample data shown.

ExerciseUpdateCallback is not triggered when wear is dim

I need to collect the latest health data from exerciseClient to send back to the phone. But it seems the ExerciseUpdateCallback is not triggered when the wear is dim ( I tested on latest build of Exercises Sample project ). How can I make it work, thanks

PassiveData - minifyEnabled true - app crashes

Is there any way we can prevent app crashes when minifyEnabled is set to true?
Is there any guide to health services regarding proguard-rules?

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

Exercise Sample App Crashes when opened - exerciseClient.capabilities returns null

The Exercise Sample App crashes immediately when run with the following error:

Process: com.example.exercise,
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Set androidx.health.services.client.data.ExerciseCapabilities.getSupportedExerciseTypes()' on a null object reference
        at com.example.exercise.HealthServicesManager.getExerciseCapabilities(HealthServicesManager.kt:57)
        at com.example.exercise.HealthServicesManager$getExerciseCapabilities$1.invokeSuspend(Unknown Source:11)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:227)
        at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:190)
        at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161)
        at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:362)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:396)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:388)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:293)
        at androidx.concurrent.futures.ToContinuation.run(ListenableFuture.kt:80)
        at androidx.concurrent.futures.DirectExecutor.execute(DirectExecutor.java:35)
        at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1215)
        at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:983)
        at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:746)
        at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.setResult(AbstractTransformFuture.java:248)
        at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:163)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:7690)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)

The issue is HealthServicesManager.kt line 57, the reason being that the exerciseClient is returning null capabilities:

suspend fun getExerciseCapabilities(): ExerciseTypeCapabilities? {
if (!capablitiesLoaded) {
   val capabilities = exerciseClient.capabilities.await()
   if (ExerciseType.RUNNING in capabilities.supportedExerciseTypes) {
      exerciseCapabilities = capabilities.getExerciseTypeCapabilities(ExerciseType.RUNNING)
   }
   capablitiesLoaded = true
   }
   return exerciseCapabilities
}

Internally, the Google Health services API is having this error:

E/JavaBinder: *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
    bad: Protocol message contained an invalid tag (zero).
        at ahy.A(PG:1)
        at ahy.A(PG:4)
        at bbb.c(PG:59)
        at bbb.i(PG:2)
        at azo.parsePartialFrom(PG:21)
        at azo.parseFrom(PG:24)
        at androidx.health.services.client.proto.RequestsProto$CapabilitiesRequest.parseFrom(PG:9)
        at androidx.health.services.client.impl.request.CapabilitiesRequest$$special$$inlined$newCreator$1.createFromParcel(PG:2)
        at androidx.health.services.client.impl.request.CapabilitiesRequest$$special$$inlined$newCreator$1.createFromParcel(PG:4)
        at qb.a(PG:2)
        at androidx.health.services.client.impl.IExerciseApiService$Stub.dispatchTransaction(PG:13)
        at qa.onTransact(PG:2)
        at android.os.Binder.execTransactInternal(Binder.java:1154)
        at android.os.Binder.execTransact(Binder.java:1123)

Connection to service is not available for package 'com.google.android.wearable.healthservices' and action 'com.google.android.wearable.healthservices.ExerciseClient'.

E/ServiceConnection: Connection to service is not available for package 'com.google.android.wearable.healthservices' and action 'com.google.android.wearable.healthservices.ExerciseClient'.
E/ServiceConnection: Connection disconnected and maximum number of retries reached.
java.util.concurrent.CancellationException: Service not available
at androidx.health.services.client.impl.ipc.internal.ServiceConnection.connect(ServiceConnection.java:145)
at androidx.health.services.client.impl.ipc.internal.ServiceConnection.enqueue(ServiceConnection.java:203)
at androidx.health.services.client.impl.ipc.internal.ConnectionManager.handleMessage(ConnectionManager.java:123)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:220)
at android.os.HandlerThread.run(HandlerThread.java:65)

SmartWatch insert record

Hello. I've tested insert record on my mobile and it works perfectly (see example). How can I insert a record from a smartwatch? Is it possible?

healthConnectClient.insertRecords(
listOf(
ExerciseSessionRecord(
startTime = start.toInstant(),
startZoneOffset = start.offset,
endTime = end.toInstant(),
endZoneOffset = end.offset,
exerciseType = ExerciseSessionRecord.ExerciseType.SWIMMING_POOL,
title = "My Swimming pool #${Random.nextInt(0, 60)}"
),
HeartRateRecord(
startTime = start.toInstant(),
startZoneOffset = start.offset,
endTime = end.toInstant(),
endZoneOffset = end.offset,
samples = samples
),
DistanceRecord(
startTime = start.toInstant(),
startZoneOffset = start.offset,
endTime = end.toInstant(),
endZoneOffset = end.offset,
distance = Length.meters((10 * Random.nextInt(20)).toDouble())
),
TotalCaloriesBurnedRecord(
startTime = start.toInstant(),
startZoneOffset = start.offset,
endTime = end.toInstant(),
endZoneOffset = end.offset,
energy = Energy.calories(((140 + Random.nextInt(20)) * 0.01))
)
)
)

`startActivityForResult` is not working if called via Flutter Method Channels

Hi. I trying to integrate the health-connect sdk in my flutter app, but while trying to navigate user to grant permission from the Health Connect app via startActivityForResult as suggested in your demo app, is not working & wouldn't open the Health app.

Attaching my code for reference,

     val healthConnectClient = HealthConnectClient.getOrCreate(activity!!.applicationContext)
        val permissionList = callToHealthConnectTypes(call)
        val intent = healthConnectClient.permissionController.createRequestPermissionActivityContract()
            .createIntent(activity!!.applicationContext, permissionList)
        activity!!.startActivityForResult(intent,1111)

Any idea to fix it or approximate deadlines for delivering a flutter plugin for the same?

Exercise Sample: Not getting Distance, Steps or Laps

The exercise sample app build is created and run in both the Wear OS emulator and Samsung Galaxy Watch (Sys ver 11) Wear OS 3.5.

But only getting the heart rate per min and calorie

The code is build without modification. Please help

Development machine Mac Moterey 12.4, Apple M1 Chip

Thanks,
Harish

App crash when opened after some time

When I open the sample app once all the permission is given for Activity sessions, the app crashes with the following error after a few attempts:

Connection to service is not available for package 'com.google.android.apps.healthdata' and action 'androidx.health.ACTION_BIND_HEALTH_DATA_SERVICE'.

I have also created a demo and at the same time when I open that app, it crashes with the same error as well.
This seems to be an issue with the HealthConnect API alpha version.

tombstone when trying to run the application

Hi,

I tried running the application on an emulator in Android studio and I see the following. I have successfully ran it before, and I haven't changed any source code. Just restarted the emulator, and tried running this morning.

ANR in com.example.exercisecompose
                                                                                                    PID: 4232
                                                                                                    Reason: executing service com.example.exercisecompose/com.example.exercisesamplecompose.service.ForegroundService
                                                                                                    Load: 0.96 / 1.11 / 0.63
                                                                                                    ----- Output from /proc/pressure/memory -----
                                                                                                    some avg10=0.00 avg60=0.00 avg300=0.00 total=0
                                                                                                    full avg10=0.00 avg60=0.00 avg300=0.00 total=0
                                                                                                    ----- End output from /proc/pressure/memory -----
                                                                                                    
                                                                                                    CPU usage from 24616ms to 0ms ago (2023-03-02 12:58:51.036 to 2023-03-02 12:59:15.652):
                                                                                                      3.9% 822/com.google.android.gms.persistent: 2.1% user + 1.7% kernel / faults: 5830 minor
                                                                                                      3.3% 3713/adbd: 0.3% user + 3% kernel / faults: 1676 minor
                                                                                                      2.9% 489/system_server: 1.5% user + 1.4% kernel / faults: 2840 minor
                                                                                                      2.9% 2657/com.android.vending: 1.2% user + 1.6% kernel / faults: 5036 minor
                                                                                                      1.7% 156/logd: 0.3% user + 1.4% kernel / faults: 4 minor
                                                                                                      0.6% 236/[email protected]: 0.4% user + 0.2% kernel
                                                                                                      0.5% 376/libgoldfish-rild: 0% user + 0.5% kernel
                                                                                                      0.5% 1335/com.google.android.gms: 0.4% user + 0.1% kernel / faults: 1849 minor
                                                                                                      0.5% 189/jbd2/dm-4-8: 0% user + 0.5% kernel
                                                                                                      0.5% 459/kworker/u8:2-events_unbound: 0% user + 0.5% kernel
                                                                                                      0.4% 7/kworker/u8:0-events_unbound: 0% user + 0.4% kernel
                                                                                                      0.4% 245/[email protected]: 0.1% user + 0.2% kernel
                                                                                                      0.4% 4147/kworker/u8:4-events_unbound: 0% user + 0.4% kernel
                                                                                                      0.3% 10/rcu_preempt: 0% user + 0.3% kernel
                                                                                                      0% 2202/com.android.vending:background: 0% user + 0% kernel / faults: 243 minor
                                                                                                      0.2% 158/servicemanager: 0% user + 0.2% kernel
                                                                                                      0.2% 658/com.google.android.wearable.sysui: 0.1% user + 0% kernel / faults: 94 minor
                                                                                                      0.2% 224/statsd: 0.1% user + 0% kernel / faults: 64 minor
                                                                                                      0.2% 258/[email protected]: 0% user + 0.2% kernel
                                                                                                      0.1% 1/init: 0% user + 0.1% kernel / faults: 31 minor
                                                                                                      0.1% 295/logcat: 0% user + 0.1% kernel
                                                                                                      0.1% 4156/logcat: 0% user + 0.1% kernel
                                                                                                      0.1% 157/lmkd: 0% user + 0.1% kernel
                                                                                                      0.1% 279/surfaceflinger: 0% user + 0% kernel
                                                                                                      0.1% 333/logcat: 0% user + 0% kernel
                                                                                                      0.1% 1377/com.google.android.wearable.app: 0% user + 0% kernel / faults: 23 minor
                                                                                                      0.1% 2471/com.google.android.gms.unstable: 0% user + 0% kernel / faults: 380 minor
                                                                                                      0.1% 3744/logcat: 0% user + 0% kernel
                                                                                                      0% 16/ksoftirqd/1: 0% user + 0% kernel
                                                                                                      0% 147/kworker/1:1H-kblockd: 0% user + 0% kernel
                                                                                                      0% 262/[email protected]: 0% user + 0% kernel
                                                                                                      0% 1351/com.google.android.wearable.healthservices: 0% user + 0% kernel / faults: 3 minor
                                                                                                      0% 1476/com.google.process.gservices: 0% user + 0% kernel / faults: 211 minor
                                                                                                      0% 3749/logcat: 0% user + 0% kernel
                                                                                                      0% 9/ksoftirqd/0: 0% user + 0% kernel
                                                                                                      0% 12/kworker/0:1-rcu_gp: 0% user + 0% kernel
                                                                                                      0% 21/ksoftirqd/2: 0% user + 0% kernel
                                                                                                      0% 128/kworker/0:1H-kblockd: 0% user + 0% kernel
                                                                                                      0% 142/kworker/3:1H-kblockd: 0% user + 0% kernel
                                                                                                      0% 169/vold: 0% user + 0% kernel
                                                                                                      0% 194/[email protected]: 0% user + 0% kernel
                                                                                                      0% 209/kworker/1:3-ipv6_addrconf: 0% user + 0% kernel
                                                                                                      0% 225/netd: 0% user + 0% kernel
                                                                                                      0% 634/com.android.bluetooth: 0% user + 0% kernel
                                                                                                      0% 764/[email protected]: 0% user + 0% kernel
                                                                                                      0% 796/androidx.wear.watchface.samples.app: 0% user + 0% kernel / faults: 21 minor
                                                                                                      0% 1602/com.google.process.gapps: 0% user + 0% kernel / faults: 15 minor
                                                                                                      0% 3795/com.google.android.contacts: 0% user + 0% kernel / faults: 7 minor
                                                                                                    5.1% TOTAL: 1.6% user + 2.1% kernel + 0% iowait + 1.1% irq + 0.2% softirq
                                                                                                    CPU usage from 11ms to 325ms later (2023-03-02 12:59:15.663 to 2023-03-02 12:59:15.977):
                                                                                                      42% 489/system_server: 25% user + 17% kernel / faults: 387 minor
                                                                                                        25% 4440/AnrConsumer: 10% user + 14% kernel
                                                                                                        17% 499/HeapTaskDaemon: 10% user + 7.1% kernel
                                                                                                      4.6% 3744/logcat: 0% user + 4.6% kernel
                                                                                                    14% TOTAL: 8.1% user + 4.8% kernel + 1.6% irq

Missing synthetic testing instructions for health events

I was wondering if there was a way for us to test the new Fall Detected health event by using the synthetic testing instructions. I would like to test how the data works with our application but I don't see any instructions on how to do that. Can I test the event by taking my watch off and dropping it in my lap or will the on body detection prevent that?

App crash when onClick session item

java.lang.NoSuchMethodError: No virtual method toHoursPart()I in class Ljava/time/Duration; or its super classes (declaration of 'java.time.Duration' appears in /apex/com.android.art/javalib/core-oj.jar)
at com.example.healthconnectsample.data.HealthConnectUtilKt.formatTime(HealthConnectUtil.kt:41)
at com.example.healthconnectsample.presentation.screen.activitysessiondetail

Collecting UserActivityInfo not working

Hello, I have encountered an issue: I am not getting new user activity info in fun onUserActivityInfoReceived(info: UserActivityInfo). To say that I do not receive at all is not entirely correct, I receive, but I receive this data immediately after I registered the service with setPassiveListenerServiceAsync and this data is outdated. Here's an log of UserActivityInfo I collected for a day:

write time to DB userActivityInfo.stateChangeTime.toMillis activity state
1 1678282350577 - 08 2023 13:32:30 1678177045675 - 07 2023 08:17:25 passive
2 1678263022160 - 08 2023 08:10:22 - end of sleep 1678177045669 - 07 2023 08:17:25 passive
3 1678223467842 - 07 2023 21:11:07 - start of sleep 1678177045676 - 07 2023 08:17:25 passive
4 1678223370897 - 07 2023 21:09:30 1678177045670 - 07 2023 08:17:25 passive
5 1678209916454 - 07 2023 17:25:16 1678177045676 - 07 2023 08:17:25 passive
6 1678208627154 - 07 2023 17:03:47 1678177045676 - 07 2023 08:17:25 passive
7 1678206676803 - 07 2023 16:31:16 1678177045676 - 07 2023 08:17:25 passive
8 1678205537674 - 07 2023 16:12:17 1678177045676 - 07 2023 08:17:25 passive
9 1678204862883 - 07 2023 16:01:02 1678177045676 - 07 2023 08:17:25 passive
10 1678204832426 - 07 2023 16:00:32 1678177045676 - 07 2023 08:17:25 passive
11 1678204827020 - 07 2023 16:00:27 1678177045676 - 07 2023 08:17:25 passive
12 1678204820542 - 07 2023 16:00:20 1678177045676 - 07 2023 08:17:25 passive
13 1678184515495 - 07 2023 10:21:55 1678177045676 - 07 2023 08:17:25 passive
14 1678179278383 - 07 2023 08:54:38 1678177045676 - 07 2023 08:17:25 passive
15 1678178784282 - 07 2023 08:46:24 1678177045676 - 07 2023 08:17:25 passive
16 1678177767542 - 07 2023 08:29:27 1678177045676 - 07 2023 08:17:25 passive
17 1678177675343 - 07 2023 08:27:55 1678177045676 - 07 2023 08:17:25 passive

All the data here, these are the ones that I received immediately after registering the service. If you say that you shouldn’t register so often, then it’s fine, I have an interval in 11 hours when I didn't registered service, it's an interval 2 and 3, there is a period of time when I slept with the watch, and in theory, between these records, there should be other activities that say that I’m asleep, but as you can see there's nothing. And that's the problem, I want to track my sleep duration but I can't because I'm not getting activity changes :(

Code

Manifest.sml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-feature android:name="android.hardware.type.watch" />

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <!-- For receiving heart rate data. -->
    <uses-permission android:name="android.permission.BODY_SENSORS" />
    <!-- For receiving steps data. -->
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
    <!-- Needed in order to re-register for data on device startup. -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <!-- Probably need for tracking activity, TODO: remove if it's not necessary -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <!-- Probably need for tracking activity, TODO: remove if it's not necessary -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

    <!-- When an app targets Android 11 (API level 30) or higher and queries for information about
         the other apps that are installed on a device, the system filters this information by
         default. Adding the query field allows Health Services to recognize the app.
         See https://developer.android.com/training/package-visibility. -->
    <queries>
        <package android:name="com.google.android.wearable.healthservices" />
    </queries>

    <queries>
        <package android:name="com.google.android.apps.healthdata" />
    </queries>

    <application
        android:name=".presentation.App"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@android:style/Theme.DeviceDefault">
        <uses-library
            android:name="com.google.android.wearable"
            android:required="true" />

        <meta-data
            android:name="com.google.android.wearable.standalone"
            android:value="true" />

        <activity
            android:name=".presentation.android.activity.MainActivity"
            android:exported="true"
            android:launchMode="singleInstance"
            android:theme="@android:style/Theme.DeviceDefault">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="android.app.lib_name"
                android:value="" />
        </activity>

        <!-- Complication -->
        <service
            android:name=".presentation.complication.PowerScoreComplicationProviderService"
            android:icon="@drawable/ic_power_score_4"
            android:label="@string/power_score"
            android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER"
            android:exported="true">
            <intent-filter>
                <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST" />
            </intent-filter>

            <meta-data
                android:name="android.support.wearable.complications.SUPPORTED_TYPES"
                android:value="SMALL_IMAGE" />
            <meta-data
                android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
                android:value="100" />
        </service>

        <service
            android:name=".presentation.android.healthservices.services.PassiveDataService"
            android:exported="true"
            android:permission="com.google.android.wearable.healthservices.permission.PASSIVE_DATA_BINDING" />

        <!-- Receiver that re-registers for background data after a device restart. -->
        <receiver
            android:name=".presentation.android.receiver.StartupReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <!-- Receiver that re-registers for background data with some interval. -->
        <receiver android:name=".presentation.android.receiver.RepeatedRegistrarReceiver" />
        <!-- Receiver that helps with scheduled notifications. -->
        <receiver android:name=".presentation.android.receiver.NotificationReceiver" />
        <!-- Receiver that helps with syncing next pvt time. -->
        <receiver android:name=".presentation.android.receiver.NextPvtTimeSyncReceiver" />
        <!-- Receiver that helps with syncing power gauge sync. -->
        <receiver android:name=".presentation.android.receiver.PowerGaugeSyncReceiver" />

        <!-- Our application implements Configuration.Provider, so we don't need this to initialize WorkManager. -->
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <!-- If you are using androidx.startup to initialize other components -->
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup"
                tools:node="remove" />
        </provider>
    </application>
</manifest>

Registered service here

    suspend fun registerListenerForFitData(dataTypes: Set<DataType<*, *>>) {
        val passiveListenerConfig = PassiveListenerConfig.builder()
            .setShouldUserActivityInfoBeRequested(shouldUserActivityInfoBeRequested = true)
            .setDataTypes(dataTypes)
            .build()

        passiveMonitoringClient.setPassiveListenerServiceAsync(
            PassiveDataService::class.java,
            passiveListenerConfig
        ).await()
    }

PassiveDataService.kt

class PassiveDataService : PassiveListenerService() {

    private val activityStateManager: ActivityStateManager by inject()
    private val job = SupervisorJob()
    private val scope = CoroutineScope(Dispatchers.IO + job)

    override fun onUserActivityInfoReceived(info: UserActivityInfo) {
        scope.launch {
            activityStateManager.addActivityState(
                activityName = info.userActivityState.toActivityName(),
                timeInMillis = info.stateChangeTime.toEpochMilli()
            )
            Log.d("TAG!", "userActivityState: ${info.userActivityState.name}")
        }
    }

    override fun onNewDataPointsReceived(dataPoints: DataPointContainer) {
    ...
    }
}

Environments:

Device: Fossil Gen 6
OS: Wear OS 3
Android SDK: 30
Lib version: 1.0.0-beta02

Notes:

  • Steps, calories and heart rate tracking work
  • I've been tracking for 4 days now and the logs for those days were the same

Thank you in advance!

Permission launcher is not working

// My codes
        if (HealthConnectClient.isAvailable(context = this)){
            // Heath Connect is available and installed
            val healthConnectClient = HealthConnectClient.getOrCreate(context = this@MainActivity)
            Toast.makeText(this@MainActivity, "Lets capture some data", Toast.LENGTH_SHORT).show()
            // Create the permissions launcher.
            val requestPermissionActivityContract = healthConnectClient.permissionController.createRequestPermissionActivityContract()

            val requestPermissions =
                registerForActivityResult(requestPermissionActivityContract) { granted ->
                    if (granted.containsAll(PERMISSIONS)) {
                        // Permissions successfully granted
                    } else {
                        // Lack of required permissions
                    }
                }
        } else{
            Toast.makeText(this@MainActivity, "Health client not found", Toast.LENGTH_SHORT).show()
        }

Hi I am working on the demo healthconnect app and trying to add the permission launcher in the onCreate() method. But it is showing error for the createRequestPermissionActivityContract , registerForActivityResult etc. I could not find any suitable example to figure out the issues. Could you please suggest what I am doing wrong. I am following this workflow
https://developer.android.com/guide/health-and-fitness/health-connect/get-started

When i click the session the app is crash

Process: com.example.healthconnectsample, PID: 6832
java.lang.IllegalStateException: Null binding
at androidx.health.platform.client.impl.ipc.internal.ServiceConnection.onNullBinding(ServiceConnection.java:374)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2080)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2110)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7842)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@66bf534, Dispatchers.Main.immediate]

Passive Goals - Not getting Steps, Calories etc. Getting only Heart_rate

Passive Goals - Not getting Steps, Calories etc. Getting only Heart_rate

Environment: Mac OSx - Android Studio IDE, Wear OS Emulator

Set daily calories - here private val dataTypes = setOf(DataType.HEART_RATE_BPM, DataType.DAILY_CALORIES)

class HealthServicesRepository(context: Context) {

private val healthServicesClient = HealthServices.getClient(context)

private val passiveMonitoringClient = healthServicesClient.passiveMonitoringClient

private val dataTypes = setOf(DataType.HEART_RATE_BPM, DataType.DAILY_CALORIES)

private val passiveListenerConfig = PassiveListenerConfig(

    dataTypes = dataTypes,

    shouldUserActivityInfoBeRequested = false,

    dailyGoals = setOf(),

    healthEventTypes = setOf()

)

......
......

But after that not get any data points on the onNewDataPointsReceived method.

class PassiveDataService : PassiveListenerService() {

private val repository = PassiveDataRepository(this)

override fun onNewDataPointsReceived(dataPoints: DataPointContainer) {

    runBlocking {

        dataPoints.getData(DataType.HEART_RATE_BPM).latestHeartRate()?.let {

            repository.storeLatestHeartRate(it)

        }

    }

}

}

Please help me to get heart rate, daily steps, daily calories, distance etc from PassiveData sample app with correct permissions, settings and flows required

Thanks in Advance

After using Wear Health Services , the accelerator sensor data cannot be sampled with the specified sample rate

I use WHS and Accelerator at the same time.

After using the HealthServices and exerciseClient to start startExercise,

the the accelerator always sampled by 100HZ, not the sample rate which i specified.

this.motionManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager
this.acc_sensor = this.motionManager!!.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)

this.SAMPLE_RATE = 20.0
this.motionManager?.registerListener(
            this,
            this.acc_sensor!!,
            (1000 * 1000 / this.SAMPLE_RATE).toInt()  //not work, the data samplerate will be 100hz
        )

Is this a bug?

BTW: Test on galaxy watch 4

PassiveData - StartupReceiver doesn't initiate registerForHeartRateData

@garanj

StartupReceiver doesn't initiate registerForHeartRateData.

Tested with -
adb root
adb shell
am broadcast -a android.intent.action.BOOT_COMPLETED -p com.example.passivedata

When restarting watch, BOOT_COMPLETED does not trigger register for background data

This error happens

2022-05-06 12:04:21.718 1697-1697/com.example.passivedata I/Passive Data Sample: Enqueuing worker
2022-05-06 12:04:21.759 1697-1738/com.example.passivedata E/WM-WorkerFactory: Could not instantiate com.example.passivedata.RegisterForBackgroundDataWorker
    java.lang.NoSuchMethodException: com.example.passivedata.RegisterForBackgroundDataWorker.<init> [class android.content.Context, class androidx.work.WorkerParameters]
        at java.lang.Class.getConstructor0(Class.java:2332)
        at java.lang.Class.getDeclaredConstructor(Class.java:2170)
        at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:95)
        at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:244)
        at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:136)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
2022-05-06 12:04:21.759 1697-1738/com.example.passivedata E/WM-WorkerWrapper: Could not create Worker com.example.passivedata.RegisterForBackgroundDataWorker

We should see >>> I/Passive Data Sample: Registering for background data.

NullPointerException in PassiveData and PassiveEvents sample projects.

I faced the next NullPointerException when I try to do "Enable" Passive Data or Passive Events on emulator Wear OS API 30:

java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.google.common.util.concurrent.ListenableFuture.cancel(boolean)' on a null object reference
        at android.os.Parcel.createExceptionOrNull(Parcel.java:2392)
        at android.os.Parcel.createException(Parcel.java:2370)
        at android.os.Parcel.readException(Parcel.java:2353)
        at android.os.Parcel.readException(Parcel.java:2295)
        at androidx.health.services.client.impl.IPassiveMonitoringApiService$Stub$Proxy.registerDataCallback(IPassiveMonitoringApiService.java:318)
        at androidx.health.services.client.impl.ServiceBackedPassiveMonitoringClient$registerDataCallbackInternal$serviceOperation$1.execute(ServiceBackedPassiveMonitoringClient.kt:122)
        at androidx.health.services.client.impl.ipc.Client$3.execute(Client.java:222)
        at androidx.health.services.client.impl.ipc.internal.ServiceConnection.execute(ServiceConnection.java:243)
        at androidx.health.services.client.impl.ipc.internal.ServiceConnection.enqueue(ServiceConnection.java:200)
        at androidx.health.services.client.impl.ipc.internal.ConnectionManager.handleMessage(ConnectionManager.java:123)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)

Not detecting any data from the Galaxy Watch 4

Is it possible for it to return all steps data from Samsung Health instead of just the phone steps using the HealthData?
I've connected Health Platform and I'm accurately reading the phone steps but steps from the watch are ignored.

I'm using a ReadTimeGroupAggregatedDataRequest

builder.addCumulativeAggregationSpec(
CumulativeAggregationSpec.builder(IntervalDataTypes.STEPS)
.setDataOrigin(DataOrigin.all())
.build());

I've tried changing DataOrigin to "all()" and "fromPlatform()" but it isn't changing anything.

Also when calling healthDataClient.getDevices(), only my phone is returned.

Are watches even supported by the HealthData client?

Thanks

Add appropriate error handling

From

try {
exerciseClient.prepareExerciseAsync(warmUpConfig).await()
} catch (e: Exception) {
Log.e(TAG, "Prepare exercise failed - ${e.message}")
}

Also https://developer.android.com/reference/androidx/health/services/client/ExerciseClient#prepareExerciseAsync(androidx.health.services.client.data.WarmUpConfig)

If the calling app already has an active exercise in progress or if it does not have the required permissions, then this call returns a failed future.

This logging of the error doesn't show a realistic example, and would silently fail without telling the user.

StepCount-Daily: Complication receives update way quicker and more often than Health-Service

Hi,
i'm currently replacing the deprecated HealthDataService with the HealthServices beta and today i noticed that the updates are quite slow.
I know - battery is important, but the updates from the passive listener is even slower then an ordinary step complication is being updated. sometimes even a few minutes. (Galaxy Watch 4 and 5 by the way)

any idea how i could solve this? i would expect that the update from the complication and the update from the service is somewhat at the same time. a few seconds would also be ok ... but minutes?

thanks for your help.

by the way:
with the deprecated HealthDataService i was able to pull the daily step counter anytime i want and receive a daily stepcount which was not more then 10-20 seconds old.
since our users are "a little impatient" i even replaced the complication and pulled the stepcount in the watchface renderer ... works fine ;-)

Question: Exercise Sample with Wear Compose

Hello,
Are you planning to show how to use properly the exercise sample with wear compose?
I don't know how to use Android Compose the right way with this example. I started with the Exercise Sample and I replaced xml views by Android Compose. However, I still keep the ExerciseFragment with almost all variables. The only thing I get rid of is _binding and binding.
The thing I don't think is right in my code is that I store some functions from the fragment in my viewModel to call it in my screen (the composable function).

To show you this, in onViewCreated of the ExerciseFragment, I did this :

    viewModel.endExerciseCallback = {
            startEndExercise()
        }

        viewModel.pauseResumeCallBack = {
            pauseResumeExercise()
        }

        viewModel.forceStartExerciseCallback = {
            forceStartExercise()
        }

        viewModel.closeServiceCallBack = {
            stopChronometer()
            unbindViewsFromService()
        }

Can you explain me what's the right way to integrate the Exercise Sample using wear Compose without a mix of the 2 system?

Thank you!

app crash after startExercise or endExercise

I got some error logs from my user's devices.

crash1:

androidx.health.services.client.impl.IExerciseApiService$Stub$Proxy.startExercise
android.os.DeadObjectException

android.os.BinderProxy.transactNative BinderProxy.java
android.os.BinderProxy.transact BinderProxy.java:567
androidx.health.services.client.impl.IExerciseApiService$Stub$Proxy.startExercise
androidx.health.services.client.impl.ServiceBackedExerciseClient.startExerciseAsync$lambda$3
androidx.health.services.client.impl.ServiceBackedExerciseClient.k
androidx.health.services.client.impl.c.execute
androidx.health.services.client.impl.ipc.Client$3.execute
androidx.health.services.client.impl.ipc.internal.ServiceConnection.execute
androidx.health.services.client.impl.ipc.internal.ServiceConnection.enqueue
androidx.health.services.client.impl.ipc.internal.ConnectionManager.handleMessage
android.os.Handler.dispatchMessage Handler.java:102
android.os.Looper.loop Looper.java:246
android.os.HandlerThread.run HandlerThread.java:67

crash2:

Package: com.xxx.myapp
Version Code: 200105
Version Name: 1.69
Android: 11
Android Build: RWS3.220419.001
Manufacturer: samsung
Model: SM-R865F
CrashReporter Key: 4b532657-4679-4bcd-9186-0015c7f59180
Start Date: 2023-05-04T09:07:17.817Z
Date: 2023-05-04T09:29:27.241Z

androidx.health.services.client.HealthServicesException: Failed to end exercise with error: com.xxx.myapp doesn't have an active exercise.
  at androidx.health.services.client.impl.internal.StatusCallback.onFailure(Unknown Source:23)
  at androidx.health.services.client.impl.internal.IStatusCallback$Stub.onTransact(Unknown Source:32)
  at android.os.Binder.execTransactInternal(Binder.java:1159)
  at android.os.Binder.execTransact(Binder.java:1123)

I can't reproduce these issues from my device, If I surround startExercise __ endExerciseAsync__ with a try catch, will that prevent the crash happening?

before:

 exerciseClient.startExerciseAsync(config).await()
....
exerciseClient.endExerciseAsync().await()

change to:

   try {
            exerciseClient.startExercise(config)
        } catch (e: Exception) {
            Log.e(TAG, "Start exercise failed - ${e.message}")
        }

    ....
        try {
            exerciseClient.endExercise()
            exerciseClient.clearUpdateCallback(this)
        } catch (e: Exception) {
            Log.e(TAG, "End exercise failed - ${e.message}")
        }

I don't know why it crashes, and those methods don't need to catch exceptions.
In addition, I'm using androidx.health:health-services-client:1.0.0-beta02

Exercise and ambient mode

I start the exercise, after a while it goes into ambient mode and the data starts coming in once a minute. i added an alarm manager and wake up the app every 5 seconds, but the health service still returns the data 1 time per minute

Request for assistance in retrieving sleep data from Health Connect API

Subject: Request for assistance in retrieving sleep data from Health Connect API

Dear Google team,

I am writing to seek your assistance in retrieving sleep data from the Health Connect API. I have attempted to retrieve this data by specifying the startTime and endTime parameters as blank, but have been unsuccessful.

I would appreciate it if you could guide me on how to retrieve sleep data from the Health Connect API, including the required parameters and their respective values. I understand that there are two types of sleep data available: sleepStage and sleepSession.

I am writing to share with you a sample of the data that we have collected thus far.

Sleep Stage
[{"endTime":{},"endZoneOffset":{},"metadata":{"clientRecordVersion":0,"dataOrigin":{"packageName":"androidx.health.connect.client.devtool"},"device":{"type":0},"id":"20848e26-1061-4ebc-b8ae-32a43249abbe","lastModifiedTime":{}},"stage":1,"startTime":{},"startZoneOffset":{}}]

Sleep Session
[{"endTime":{},"endZoneOffset":{},"metadata":{"clientRecordVersion":0,"dataOrigin":{"packageName":"androidx.health.connect.client.devtool"},"device":{"type":0},"id":"f38a99b5-e72f-4148-a937-b6ca587ba690","lastModifiedTime":{}},"notes":"Notes","startTime":{},"startZoneOffset":{},"title":"Title"}]

Thank you for your time and assistance.

Sincerely,
Sagar

Exercise Sample - WCS SDK Client 'HealthServicesExerciseClient' disconnected in Wear OS 3.5

I tried running the project in wear os 3.5 but got the problem, please check it.
WCS SDK Client 'HealthServicesExerciseClient' disconnected, retrying connection. Retry attempt: 0 java.util.concurrent.CancellationException at androidx.health.services.client.impl.ipc.internal.ServiceConnection.lambda$cleanOnDeath$0$androidx-health-services-client-impl-ipc-internal-ServiceConnection(ServiceConnection.java:308) at androidx.health.services.client.impl.ipc.internal.ServiceConnection$$ExternalSyntheticLambda0.binderDied(Unknown Source:2) at android.os.IBinder$DeathRecipient.binderDied(IBinder.java:305) at android.os.BinderProxy.sendDeathNotice(BinderProxy.java:685)

SWIMMING_OPEN_WATER distance 0 in real time

Hello. I use ExerciseType.SWIMMING_OPEN_WATER.
val dataTypes = setOf(
DataType.HEART_RATE_BPM,
DataType.LOCATION, DataType.DISTANCE,
).intersect(capabilities.supportedDataTypes)

    val aggDataTypes = setOf(
        DataType.TOTAL_CALORIES,
        DataType.DISTANCE,
        DataType.LOCATION, // +++
        DataType.SWIMMING_STROKES
    ).intersect(capabilities.supportedDataTypes)

Usually, I see responses distance 0, but when I call exerciseClient.endExercise().await() I see total distance.
For ExerciseType.SWIMMING_POOL distance works.
How to get the distance in real time?

MeasureData and ExerciseSample - both don't measure BPM rate when screen is off

Hi,
I am trying MeasureData and ExerciseSample because I need create an app that measure your BPM rate every second and check if is above or below the limit (if has - alarm should appear).

When you have MeasureData app open - it is working and showing your actual BPM rate. But when you tilt your wrisp and screen goes off - it will stop measure. Same as ExerciseSample. I found it out in log. I am connected with real device to AndroidStudio and checking log. When screen is off - log stop showing bpm rate.

Is there any way (ideally for MeasureData) to keep alive measuring BPM when display is off?

Measure Data sample app only recognizes Heart Rate capability

Hello, I'm using the Measure Data sample app, with the latest dependency:
implementation "androidx.health:health-services-client:1.0.0-alpha03"

The issue I'm finding is that the MeasureClient capabilities returns only heart rate, while the device I'm using (Galaxy Watch 5/5pro) has way more sensors that can be used.

What am i missing ?

All health services are not working

Hi! Are all the health services included in DataType working?ExerciseTypeCapabilities doesn't log all the data types. Am not getting the data for speed/pace/floors etc. Same goes for MeasureTypeCapabilities-it only returns HEART_RATE_BPM. Do they work or there's something I'm missing out here. Please shed some light here sot hat I can be sure of what to follow next. Thanks in advance

Which one do you mean to installed?

I downloaded the sample and checked the following problems during execution.

Health Connect is supported on this device, but is not currently installed"

Which one do you mean to installed?


image

It is possible to obtain running and swimming metrics in the same exercise?

It is possible to obtain running and swimming metrics in the same exercise? I know I can get the running metrics by setting the type of sport like RUNNING and the swimming metrics by setting the type as SWIMMING_POOL, but can I get both at the same time? In certain sports this can be very useful as triathlon.

exerciseState.isEnding is not appearing

with emulator(0.0.6), exerciseState.isEnding appear and It work properly to navigate to summary by pressing END button

but with GW4/5 (healthservices 0.18., android 11, API 30) and emulator(0.14., android 11, API 30) to test exercisesamplecompose,
exerciseState.isEnding dont't appear, rarely appeared at emulator, never at GW4/5
ACTIVE to ENDED, or ACTIVE TO briefly PAUSING/PAUSED TO ENDED when I press END button

os I change the code like:
if (exerciseStateChange.exerciseState.isEnding) ->
if (exerciseStateChange.exerciseState.isEnded && activeDuration.toKotlinDuration().isPositive())
why I put activeDuration is that it prevent to end at the very begining with chance of having exerciseState.isEnded initially

it works well but Do you think this could cause problem?

Issue with Synthetic Data

I have downloaded this project and tested with a couple of watches and an emulator but I haven't been able to get synthetic data to register in the app. I start the exercise client app, then use the adb commands however I do not see any activity within the app. Has anyone else had this issue or know how to fix it?

readSessionsList: Session StringField title does not exist.

When I generate a running exercise from Samsung Galaxy 4 watch then sync to Samsung health app.
(I had installed Health Platform).
Then run the health-samples,it crashes at HealthPlatformManager.kt(line 118).
java.lang.IllegalArgumentException: StringField title does not exist.

The following is the log:
com.example.healthplatformsample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.healthplatformsample, PID: 24891
java.lang.IllegalArgumentException: StringField title does not exist
at com.google.android.libraries.healthdata.data.DataValueHelper.zzp(com.google.android.libraries.healthdata:health-data-api@@1.0.0-alpha01:2)
at com.google.android.libraries.healthdata.data.IntervalData.getStringValue(com.google.android.libraries.healthdata:health-data-api@@1.0.0-alpha01:3)
at com.example.healthplatformsample.data.HealthPlatformManager.readSessionsList(HealthPlatformManager.kt:118)
at com.example.healthplatformsample.data.HealthPlatformManager$readSessionsList$1.invokeSuspend(Unknown Source:14)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Measure Data does not work in the latest version of the wear os emulator.

in HealthServicesManager.kt

val callback = object: MeasureCallback {
override fun onAvailabilityChanged(dataType: DataType, availability: Availability) {
sendBlocking(MeasureMessage.MeasureAvailabilty(availability))
}

         override fun onData(data: List<DataPoint>) {
             sendBlocking(MeasureMessage.MeasureData(data))
         }
     }

onAvailabilityChanged is called twice. (availability : ACQUIRING, UNAVAILABLE)
onData is not called.

Passive Data Sample doesn't work

Hello guys, I faced the issue when the sample app displays 0 heart rate.
I think PassiveDataService doesn't catch HEART_RATE_BPM, so I modified code and added passiveListenerCallback, but even there I don't receive heart rate. But when I replaced HEART_RATE_BPM with STEPS_DAILY, there weren't problems with receiving steps though.
I don't think the issue in my watch, because in Google Fit app I can see my heart rate (min, max, etc.). But for your information it's Fossil Gen 6 (Wear OS 3).
Any thoughts what's wrong? Any help would be helpful, thank you!

Emulator crashing on launching the app

The app is working fine on my watch, but it stops once launched. Checking the logcat gives me this. Developer options are activated in the emulator.

--------- beginning of crash
2022-12-16 21:48:06.472  6992-6992  AndroidRuntime          com.terrencealuda.tcardio            E  FATAL EXCEPTION: main
                                                                                                    Process: com.terrencealuda.tcardio, PID: 6992
                                                                                                    java.lang.Exception: Not yet implemented
                                                                                                    	at androidx.health.services.client.impl.internal.StatusCallback.onFailure(StatusCallback.kt:42)
                                                                                                    	at androidx.health.services.client.impl.internal.IStatusCallback$Stub.onTransact(IStatusCallback.java:80)
                                                                                                    	at android.os.Binder.execTransactInternal(Binder.java:1159)
                                                                                                    	at android.os.Binder.execTransact(Binder.java:1123)
                                                                                                    	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@bca20c9, Dispatche

@breanatate, could you assist?

Can't prepareExercise on Wear OS 3.5 device (galaxy watch 5)

I am using exercisesamplecompose on emulator and galaxy watch 5. emulator is ok. but it doesn't work on real device
first of all, It can't get locationAvailability(GPS), so keep showing ProgrssBar,
anyway when I proceed GO without properly prepared, it does not seems like binding foregroundservice to activity, when I press STOP, it doesn't show unbind on Logcat, and when I press RESTART, app is terminated forcibly and log tell me there's no active exercise

Problem adding more types of exercises

I can't add another exercise If I try to add another exercise apart from running and try to execute the other type of exercise I never take the data of the new exercise but those of running. Why could this happen? Is there an example where two types of exercise are implemented to observe that it could be failing?

Launching Permissions Request stops working after 2 tries

Subsequent attempts seem to just call back with an empty array. For HealthConnectSample, each different request seems to work twice, then ceases to function. After permissions have been denied twice, the user must navigate into Health Connect Settings and either toggle on and off access for the app, or remove access for all apps.

If this is intentional it would be good to have some programmatic way to check if requests are being blocked.

androidx.health.connect:connect-client:1.0.0-alpha06
Health Connect 0.1.1153.480892628.0-open_beta

Google Pixel 4a, Android 12, Build number SQ3A.220705.003.A1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.