Vücut sensörü verilerine arka planda erişim isteme
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Android 13 ve Wear OS 4, uygulamaların vücut sensörlerine erişmesine olanak tanıyan bir yöntem sunuyor. Örneğin:
arka planda çalıştırmaya devam ediyor. Bu yeni erişim modeli, erişim modeline benzer
Android 10'da (API düzeyi 29) arka planda konum erişimini kullanıma sunduk.
Gizlilikle ilgili en iyi uygulamalar sayfasında açıklandığı gibi, uygulamalar yalnızca
kullanımı açısından kritik öneme sahip olduğu durumlarda BODY_SENSORS_BACKGROUND iznini
ve bunu kullanıcılara uygun şekilde açıklamalıdır.
İzin verme süreci, uygulamanızın hedef SDK'sına bağlıdır
sürümünü değil.
Uygulama Android 13 veya sonraki sürümleri hedefliyor
Mevcut BODY_SENSORS iznine ek olarak
Manifest dosyanızda BODY_SENSORS_BACKGROUND izni:
Ardından, uygulamanızın izinleri ayrı işlemlerde istemesi gerekir:
BODY_SENSORS için izin verilip verilmediğini kontrol edin. Değilse izin isteyin.
BODY_SENSORS_BACKGROUND için izin verilip verilmediğini kontrol edin. Aksi halde
izni gerekir.
Şekil 1. Sensör ayarı, Tüm
süre'yi seçin.
Dikkat: Uygulamanız hem vücut sensörü izinlerini hem de
aynı zamanda sistem isteği yoksayar ve uygulamanıza da
izni gerekir.
Android 13 (API düzeyi 33) ve sonraki sürümlerde çalışma zamanında istenen izin iletişim kutusu
"Her zaman izin ver" seçeneğini seçeneğini belirleyin. Bunun yerine kullanıcıların her zaman
arka planda sensör erişimine izin verin (Şekil 1'de gösterildiği gibi). Google Takvim widget'ını
şunu verdikten sonra BODY_SENSORS_BACKGROUND iznini iste
BODY_SENSORS iznini kullanmak için kullanıcıların bu ayarlar sayfasına gitmesine yardımcı olabilirsiniz. Eğer
erişimi her zaman reddettiklerinde, bağlantı bilgilerinizi kullanmaya devam edebilmeleri gerekir.
uygulamasını indirin.
Uygulama daha eski bir sürümü hedefliyor
Şekil 2. İzin iletişim kutusunda, kullanıcıların
uygulamanın sensör izinlerini kontrol edin.
Uygulamanız Android 13'ten önceki bir Android sürümünü hedeflediğinde arka plan
BODY_SENSORS isteğinde bulunduğunuzda erişim izni otomatik olarak verilmez
izni gerekir. Bunun yerine, kullanıcılar kullanıcıları şuraya davet eden bir sistem iletişim kutusu görür:
uygulamanızın sensör izni ayarlarını Şekil 2'de gösterildiği gibi değiştirebilirsiniz. Ardından kullanıcılar
arka plan sensörü kullanımını etkinleştirin.
Kullanıcılar arka planda erişimi reddedebilir. Bu,
Uygulamanız arka planda çalışırken BODY_SENSORS izni. Bir
Uygulama arka plan erişim izni olmadan PassiveMonitoringClient kullanıyor
arka plana gittiğinde uygulama BODY_SENSORS iznini kaybeder ve
onPermissionLost() geri çağırması çağrılır. Bu nedenlerden ötürü,
çalışma zamanı isteme ile ilgili en iyi uygulamaları izlemeniz
izin verir.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-07-27 UTC."],[],[],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."]]