[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Request background access to body sensor data\n\nAndroid 13 and Wear OS 4 introduce a way for apps to access body sensors, such\nas heart rate, from the background. This new access model is similar to the one\nthat introduced [background location access in Android 10 (API level 29)](/training/location/permissions#request-background-location).\n\nIf your app needs to access body sensor information in background, such as when\n[monitoring Health Services data in the background](/health-and-fitness/guides/health-services/monitor-background), you must request the\n[`BODY_SENSORS_BACKGROUND`](/reference/android/Manifest.permission#BODY_SENSORS_BACKGROUND) permission.\n| **Note:** `BODY_SENSORS_BACKGROUND` is a restricted permission which cannot be held by your app until the installer adds your app to an allowlist, or until the user lets your app have the permission.\n\nAs described on the [privacy best practices](/privacy/best-practices) page, apps should only ask for\nthe `BODY_SENSORS_BACKGROUND` permission when it is critical to the user-facing\nfeature, and they should properly disclose this to users.\n\nThe process for granting the permission depends on your app's target SDK\nversion.\n\nApp targets Android 13 or higher\n--------------------------------\n\nIn addition to the existing [`BODY_SENSORS`](/reference/android/Manifest.permission#BODY_SENSORS) permission, declare the\n`BODY_SENSORS_BACKGROUND` permission in your manifest file: \n\n \u003cuses-permission android:name=\"android.permission.BODY_SENSORS\"\u003e\n \u003cuses-permission android:name=\"android.permission.BODY_SENSORS_BACKGROUND\"\u003e\n\nThen, your app must [request](/training/permissions/requesting) the permissions in separate operations:\n\n1. Check if `BODY_SENSORS` is granted. If not, request the permission.\n2. Check if `BODY_SENSORS_BACKGROUND` is granted. If not, request the permission.\n\n**Figure 1.** Sensors setting includes an option called **All the\ntime**, which grants background sensor data access. \n**Caution:** If your app requests both body sensor permissions at the\nsame time, the system ignores the request and doesn't grant your app either\npermission.\n\nOn Android 13 (API level 33) and higher, the runtime permission dialog doesn't\ninclude the \"Allow all the time\" option. Instead, users must enable all-the-time\nbackground sensor access from system settings, as shown in figure 1. When you\nrequest the `BODY_SENSORS_BACKGROUND` permission after granting the\n`BODY_SENSORS` permission, you can help users navigate to this settings page. If\nusers decline all-the-time access, they should be able to continue using your\napp.\n\n\u003cbr /\u003e\n\nApp targets an earlier version\n------------------------------\n\n**Figure 2.** Permission dialog includes a link to navigate users to the app's sensor permissions in system settings.\n\nWhen your app targets a version of Android earlier than Android 13, background\naccess isn't granted automatically when you request the `BODY_SENSORS`\npermission. Instead, users see a system dialog that invites users to navigate to\nyour app's sensor permission settings, as shown in figure 2. Then, users must\nenable background sensor usage on that settings page.\n\nUsers can decline the background access. It has the same effect as revoking the\n`BODY_SENSORS` permission while your app is running in the background. When an\napp is using [`PassiveMonitoringClient`](/reference/kotlin/androidx/health/services/client/PassiveMonitoringClient) without background access permission\nand goes into the background, the app loses the `BODY_SENSORS` permission, and\nthe [`onPermissionLost()`](/reference/kotlin/androidx/health/services/client/PassiveListenerService#onPermissionLost()) callback is called. For these reasons, it's\nespecially important that you follow best practices for requesting runtime\npermissions."]]