You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Health Connect provides a special permission that allows your app to read health data in the background. This is useful for apps that need to monitor health data continuously, such as fitness tracking apps.
8
+
9
+
## Setup
10
+
11
+
### 1. Add the permission to your AndroidManifest.xml
12
+
13
+
First, you need to declare the background access permission in your app's `AndroidManifest.xml` file:
Under the hood, this permission maps to `HealthPermission.PERMISSION_READ_HEALTH_DATA_IN_BACKGROUND` in the Android Health Connect API. This permission allows your app to read health data even when it's not in the foreground.
42
+
43
+
## Checking for Background Access
44
+
45
+
You can check if your app has been granted background access permission using the `getGrantedPermissions` method:
Copy file name to clipboardExpand all lines: docs/docs/api/overview.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,3 +20,10 @@ title: Overview
20
20
| aggregateRecord | Reads aggregated results according to requested read criteria, for e.g, data origin filter and within a time range. |
21
21
| deleteRecordsByUuids | Deletes one or more records by their identifiers. Deletion of multiple records is executed in a single transaction - if one fails, none is deleted. |
22
22
| deleteRecordsByTimeRange | Deletes any record of the given record type in the given time range (automatically filtered to a record belonging to the calling application). Deletion of multiple records is executed in a transaction - if one fails, none is deleted. |
23
+
| requestExerciseRoute | Requests permission to access exercise route data for a specific exercise session. |
You can read more about data types and permissions [here](https://developer.android.com/guide/health-and-fitness/health-connect/data-and-data-types/data-types).
162
+
163
+
## Special Permissions
164
+
165
+
In addition to the standard record type permissions, Health Connect provides special permissions for specific functionality:
166
+
167
+
### Background Access Permission
168
+
169
+
This permission allows your app to read health data in the background, even when your app is not in the foreground.
170
+
171
+
First, add the background access permission to your `AndroidManifest.xml`:
0 commit comments