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.
Google Fit'teki her veri noktasının ilişkili bir veri kaynağı vardır. Veri kaynakları
bu verileri toplayan veya kullanan uygulamayı ya da cihazı tanımlayan bilgiler
verileri dönüştürür. Uygulamanın paket adı, fiziksel bir sensörü temsil etmeyen veri kaynakları için kullanılabilir.
Google Fit ile şunları yapabilirsiniz:
Belirli bir uygulamayla ilişkili verileri görüntülemek için bir intent çağırın.
Uygulamanızı kullanarak veri göstermek için niyet alın.
Hangi uygulamanın oturum eklediğini öğrenin. Daha fazla
Oturumlarla çalışma başlıklı makaleyi inceleyin.
Hangi uygulamanın veri noktası eklediğini belirleme
Uygulamanızı diğer sağlık ve sağlıklı yaşam uygulamalarından niyet almak üzere kaydetmek için:
manifestinizde aşağıdakine benzer bir intent filtresi bildirin:
Uygulamanızın Google Fit'ten aldığı her intent tek bir türdedir ancak tek bir intent filtresinde birden fazla MIME türüne göre filtreleme yapabilirsiniz. Uygulamanızın intent filtresi, özel veri türleri dahil olmak üzere uygulamanızın desteklediği tüm veri türlerini içermelidir.
Fitness intent'leri aşağıdaki ekstraları içerir:
vnd.google.gms.fitness.start_time
vnd.google.gms.fitness.end_time
vnd.google.gms.fitness.data_source
Bu ekstralardan aşağıdaki şekilde veri alabilirsiniz:
Kotlin
overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)...valsupportedType=DataType.getMimeType(DataType.TYPE_STEP_COUNT_DELTA)if(Intent.ACTION_VIEW==intent.action && supportedType==intent.type){// Get the intent extrasvalstartTime=Fitness.getStartTime(intent,TimeUnit.MILLISECONDS);valendTime=Fitness.getEndTime(intent,TimeUnit.MILLISECONDS)valdataSource=DataSource.extract(intent)}}
Java
@OverridepublicvoidonCreate(@NullableBundlesavedInstanceState){super.onCreate(savedInstanceState);...StringsupportedType=DataType.getMimeType(DataType.TYPE_STEP_COUNT_DELTA);if(Intent.ACTION_VIEW.equals(getIntent().getAction()) && supportedType.equals(getIntent().getType()){// Get the intent extraslongstartTime=Fitness.getStartTime(getIntent(),TimeUnit.MILLISECONDS);longendTime=Fitness.getEndTime(getIntent(),TimeUnit.MILLISECONDS);DataSourcedataSource=DataSource.extract(getIntent());}}
Özel bir veri türünün MIME türünü almak için MIME_TYPE_PREFIX sabit değerini kullanın:
// Inside your activityvalstartTime=...valendTime=...valdataSource=...valdataType=...valfitIntent=HistoryApi.ViewIntentBuilder(this,dataType).setTimeInterval(startTime,endTime,TimeUnit.MILLISECONDS).setDataSource(dataSource)// Optional if a specific data source is desired.setPreferredApplication("com.example.app")// Optional if you'd like a// specific app to handle the intent if that app is installed on the device.build()
Java
// Inside your activitylongstartTime=...longendTime=...DataSourcedataSource=...DataTypedataType=...IntentfitIntent=newHistoryApi.ViewIntentBuilder(this,dataType).setTimeInterval(startTime,endTime,TimeUnit.MILLISECONDS).setDataSource(dataSource)// Optional if a specific data source is desired.setPreferredApplication("com.example.app")// Optional if you'd like a// specific app to handle the intent if that app is installed on the device.build();
[null,null,["Son güncelleme tarihi: 2025-08-31 UTC."],[[["\u003cp\u003eGoogle Fit allows developers to identify the source of fitness data, including the app or device that collected it.\u003c/p\u003e\n"],["\u003cp\u003eApps can be registered to receive intents from other health apps, enabling them to display and utilize fitness data.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can initiate intents to view specific fitness data within other apps, fostering interoperability between health platforms.\u003c/p\u003e\n"],["\u003cp\u003eData sources in Google Fit contain identifying information, including package names for apps, and are linked to individual data points.\u003c/p\u003e\n"]]],[],null,["# Data attribution\n\nEvery data point in Google Fit has an associated data source. Data sources\ncontain information that identifies the app or the device that collects or\ntransforms the data. The package name of the app is available for data sources\nthat don't represent a physical sensor.\n\nGoogle Fit lets you do the following:\n\n- Invoke an intent to view data that's associated with a specific app.\n- Receive intents to show data using your app.\n- Find out which app inserted a [session](/fit/sessions). For more information, see [Work with sessions](/fit/android/using-sessions).\n\nDetermine which app inserted a data point\n-----------------------------------------\n\nTo obtain the package name of the application that inserted a data point, first\ncall [`DataPoint.getOriginalDataSource`](/android/reference/com/google/android/gms/fitness/data/DataPoint#public-datasource-getoriginaldatasource)\nto get the data source, then call the\n[`DataSource.getAppPackageName`](/android/reference/com/google/android/gms/fitness/data/DataSource#public-string-getapppackagename)\nmethod: \n\n### Kotlin\n\n```kotlin\nval dataPoint : DataPoint = ...\nval dataSource = dataPoint.originalDataSource\nval appPkgName = dataSource.appPackageName\n```\n\n### Java\n\n```java\nDataPoint dataPoint = ...\nDataSource dataSource = dataPoint.getOriginalDataSource();\nString appPkgName = dataSource.getAppPackageName();\n```\n\nReceive intents from other apps\n-------------------------------\n\nTo register your app to receive intents from other health and wellness apps,\ndeclare an intent filter in your manifest that's similar to the following: \n\n```xml\n\u003cintent-filter\u003e\n \u003caction android:name=\"vnd.google.fitness.VIEW\" /\u003e\n \u003cdata android:mimeType=\"vnd.google.fitness.data_type/com.google.step_count.cumulative\" /\u003e\n \u003cdata android:mimeType=\"vnd.google.fitness.data_type/com.google.step_count.delta\" /\u003e\n\u003c/intent-filter\u003e\n```\n| **Note:** Don't include the `DEFAULT` category in your intent filter, unless you want your app to receive intents for data created by other apps.\n\nEach intent that your app receives from Google Fit is of only one type,\nbut you can filter for multiple MIME types in a single intent filter. Your app's\nintent filter needs to include all of the data types that your app supports,\nincluding custom data types.\n\nThe fitness intents include the following extras:\n\n- `vnd.google.gms.fitness.start_time`\n- `vnd.google.gms.fitness.end_time`\n- `vnd.google.gms.fitness.data_source`\n\nYou can obtain data from these extras as follows: \n\n### Kotlin\n\n```kotlin\noverride fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n ...\n val supportedType = DataType.getMimeType(DataType.TYPE_STEP_COUNT_DELTA)\n\n if (Intent.ACTION_VIEW == intent.action && supportedType == intent.type) {\n // Get the intent extras\n val startTime = Fitness.getStartTime(intent, TimeUnit.MILLISECONDS);\n val endTime = Fitness.getEndTime(intent, TimeUnit.MILLISECONDS)\n val dataSource = DataSource.extract(intent)\n }\n}\n```\n\n### Java\n\n```java\n@Override\npublic void onCreate(@Nullable Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n ...\n String supportedType = DataType.getMimeType(DataType.TYPE_STEP_COUNT_DELTA);\n\n if (Intent.ACTION_VIEW.equals(getIntent().getAction()) && supportedType.equals(getIntent().getType())\n {\n // Get the intent extras\n long startTime = Fitness.getStartTime(getIntent(), TimeUnit.MILLISECONDS);\n long endTime = Fitness.getEndTime(getIntent(), TimeUnit.MILLISECONDS);\n DataSource dataSource = DataSource.extract(getIntent());\n }\n}\n```\n\nTo obtain the MIME type for a custom data type, use the\n[`MIME_TYPE_PREFIX`](/android/reference/com/google/android/gms/fitness/data/DataType#public-static-final-string-mime_type_prefix)\nconstant: \n\n### Kotlin\n\n```kotlin\nval supportedType = DataType.MIME_TYPE_PREFIX + \"com.company.customdatatype\"\n```\n\n### Java\n\n```java\nString supportedType = DataType.MIME_TYPE_PREFIX + \"com.company.customdatatype\";\n```\n\nInvoke an intent to view data\n-----------------------------\n\nTo invoke an intent to view data with another app, use the\n[`HistoryApi.ViewIntentBuilder`](/android/reference/com/google/android/gms/fitness/HistoryApi.ViewIntentBuilder)\nclass: \n\n### Kotlin\n\n```kotlin\n// Inside your activity\nval startTime = ...\nval endTime = ...\nval dataSource = ...\nval dataType = ...\n\nval fitIntent = HistoryApi.ViewIntentBuilder(this, dataType)\n .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)\n .setDataSource(dataSource) // Optional if a specific data source is desired\n .setPreferredApplication(\"com.example.app\") // Optional if you'd like a\n // specific app to handle the intent if that app is installed on the device\n .build()\n```\n\n### Java\n\n```java\n// Inside your activity\nlong startTime = ...\nlong endTime = ...\nDataSource dataSource = ...\nDataType dataType = ...\n\nIntent fitIntent = new HistoryApi.ViewIntentBuilder(this, dataType)\n .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)\n .setDataSource(dataSource) // Optional if a specific data source is desired\n .setPreferredApplication(\"com.example.app\") // Optional if you'd like a\n // specific app to handle the intent if that app is installed on the device\n .build();\n```\n\nLearn more about how to use [intents and intent\nfilters](https://developer.android.com/guide/components/intents-filters)."]]