Google Fit REST API de dahil olmak üzere Google Fit API'lerinin desteği 2026'da sonlandırılacak. 1 Mayıs 2024'ten itibaren geliştiriciler bu API'leri kullanmak için kaydolamaz.
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Android izinleri, Android kullanıcılarının gizliliğini korumayı amaçlar. İstemleri
Uygulamalar kişiler veya fotoğraflar gibi hassas verilerle ilgili veri türlerine erişmek istediğinde kullanıcı ve
konum veya adım algılama gibi sistem özellikleridir. Kullanıcılar, uygulamanızı ilk kez indirirken bu izinleri verir.
Uygulamanızın bu veri türlerinden herhangi birine (Google Fit veri türlerinin bir alt kümesi) erişmesi gerekiyorsa OAuth izinlerini istemeden önce ilgili Android iznini isteyin.
Aşağıya bakın.
Google Fit API'leriyle yukarıdaki veri türlerine erişmek için:
Hem Android 10 hem de Android 10 için Android izni isteme mantığını uygulayın.
Android'in önceki sürümleri. Bu örneklerde ACTIVITY_RECOGNITION izni kullanılmaktadır.
Android 10
Böylece uygulamanız API düzeyi 29 veya sonraki sürümleri hedefleyebilir, kullanıcıdan izin isteyebilir ve izni uygulama manifest dosyasına kaydedebilir.
if(ContextCompat.checkSelfPermission(thisActivity,Manifest.permission.ACTIVITY_RECOGNITION)!=PackageManager.PERMISSION_GRANTED){// Permission is not granted}
[null,null,["Son güncelleme tarihi: 2025-08-31 UTC."],[[["\u003cp\u003eAndroid permissions protect user privacy by requiring apps to request access to sensitive data and system features.\u003c/p\u003e\n"],["\u003cp\u003eApps need to request specific Android permissions before accessing certain Google Fit data types, such as activity, location, and heart rate data.\u003c/p\u003e\n"],["\u003cp\u003eDifferent data types require different permissions, like \u003ccode\u003eACTIVITY_RECOGNITION\u003c/code\u003e for step count and activity data, \u003ccode\u003eACCESS_FINE_LOCATION\u003c/code\u003e for location data, and \u003ccode\u003eBODY_SENSORS\u003c/code\u003e for heart rate data.\u003c/p\u003e\n"],["\u003cp\u003eRequesting Android permissions involves adding them to the manifest file and implementing logic to handle permission requests for different Android versions.\u003c/p\u003e\n"],["\u003cp\u003eApps targeting older Android versions should be updated to handle potential permission revocations by users on Android 10 and above.\u003c/p\u003e\n"]]],[],null,["# Android Permissions\n\n[Android permissions](https://developer.android.com/guide/topics/permissions/overview) aim to protect the privacy of an Android user. They prompt\nthe user when apps want to access data types for sensitive data like contacts or photos, and\nsystem features like location or step detection. Users grant these permissions\nwhen first downloading your app.\n\nIf your app needs access to any of [these data types](#data_types_that_need_android_permissions)\n(a subset of the Google Fit data types), request the relevant\nAndroid permission before requesting the OAuth permissions.\n[See below](#requesting_android_permissions).\n**Figure 1.**The Android permissions consent screen.\n\n*** ** * ** ***\n\nData types that need Android permissions\n----------------------------------------\n\nTo access these physical activity data types, you'll need to [request the `ACTIVITY_RECOGNITION` Android permission](#requesting_android_permissions):\n\n- To [record](/android/reference/com/google/android/gms/fitness/RecordingClient) these data types:\n\n - `com.google.step_count.delta`\n - `com.google.step_count.cumulative`\n - `com.google.step_count.cadence`\n - `com.google.activity.segment`\n - `com.google.calories.expended`\n- To [read](/android/reference/com/google/android/gms/fitness/HistoryClient) these data types:\n\n - `com.google.step_count.delta`\n - `com.google.step_count.cumulative`\n - `com.google.step_count.cadence`\n - `com.google.activity.segment`\n - `com.google.activity.exercise`\n\nTo access these data types, you'll need to [request the `ACCESS_FINE_LOCATION` Android permission](https://developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION):\n\n- To read these data types:\n - `com.google.distance.delta`\n - `com.google.location.sample`\n - `com.google.location.bounding_box`\n - `com.google.speed`\n\nTo [record](/android/reference/com/google/android/gms/fitness/RecordingClient) these data types, you'll need to [request the `BODY_SENSORS` Android permission](https://developer.android.com/reference/android/Manifest.permission.html#BODY_SENSORS):\n\n- `com.google.heart_rate.bpm`\n\nRequesting Android permissions\n------------------------------\n\nLearn about [requesting Android permissions](https://developer.android.com/training/permissions/requesting), the\n[physical activity recognition permission](https://developer.android.com/about/versions/10/privacy/changes#physical-activity-recognition), the\n[fine location permission](https://developers.google.com/maps/documentation/android-sdk/location#location_permissions), and the [body sensors permission](https://developer.android.com/reference/android/Manifest.permission.html#BODY_SENSORS).\n\nTo access the data types above with the Google Fit APIs, you'll need to\nimplement logic to handle requesting Android permissions for both Android 10 and\nprevious versions of Android. These examples use the [`ACTIVITY_RECOGNITION`](https://developer.android.com/reference/android/Manifest.permission#ACTIVITY_RECOGNITION) permission. \n\n### Android 10\n\nSo your app can target API level 29 or above, request the permission from the\nuser, and register the permission in the application manifest file.\n\n1. [Add the permission to the manifest file](https://developer.android.com/training/permissions/requesting#perm-add).\n\n \u003cuses-permission android:name=\"android.permission.ACTIVITY_RECOGNITION\"/\u003e\n\n2. [Check if the permission is granted](https://developer.android.com/training/permissions/requesting#perm-check):\n\n if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.ACTIVITY_RECOGNITION)\n != PackageManager.PERMISSION_GRANTED) {\n // Permission is not granted\n }\n\n3. If permission isn't already granted, request the permission:\n\n ActivityCompat.requestPermissions(thisActivity,\n arrayOf(Manifest.permission.ACTIVITY_RECOGNITION),\n MY_PERMISSIONS_REQUEST_ACTIVITY_RECOGNITION)\n\n### Android 9 and below\n\nSo your app can target API level 28 or below:\n\n1. Request the `com.google.android.gms.permission.ACTIVITY_RECOGNITION` permission.\n\n2. [Add the permission to the manifest file](https://developer.android.com/training/permissions/requesting#perm-add).\n\n \u003cuses-permission android:name=\"android.gms.permission.ACTIVITY_RECOGNITION\"/\u003e\n\n| **Caution:** If your app targets API level 28 or below but is running on Android 10, the `com.google.android.gms.permission.ACTIVITY_RECOGNITION` permission is converted into a pre-granted runtime permission which can be revoked by the user. If revoked, your app's access to these [physical activity\n| data types](#data_types_that_need_android_permissions) will be blocked. Update your app to handle this situation."]]