Interfejsy Google Fit API, w tym interfejs Google Fit API typu REST, zostaną wycofane w 2026 roku. Od 1 maja 2024 r. deweloperzy nie mogą rejestrować się w celu korzystania z tych interfejsów API.
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Interfejsy Google Fit API na Androida są częścią Usług Google Play. Interfejsy Google Fit API są obsługiwane na Androidzie 4.1 (poziom API 16) i nowszych. Dzięki nim może:
Odczytywanie danych historycznych i danych w czasie zbliżonym do rzeczywistego, w tym danych z urządzeń Bluetooth Low Energy (BLE).
Rejestruj działania.
Powiąż dane z sesją.
Ustal cele fitness.
Odczytywanie danych z czujnika
Jeśli aplikacja dostarcza informacji o aktywności użytkownika, na przykład o codziennych krokach, warto wyświetlać dane o ruchu użytkownika w czasie zbliżonym do rzeczywistego.
Interfejs Sensors API zapewnia dostęp do strumieni nieprzetworzonych danych zawierających te informacje. Dane te mogą pochodzić z czujników dostępnych w urządzeniach z Androidem, a także z czujników w urządzeniach do noszenia, np. w urządzeniach do noszenia.
Rejestruj dane
Jeśli Twoja aplikacja musi zbierać, przechowywać i synchronizować dane o aktywności fizycznej użytkownika, możesz skorzystać z interfejsu Recording API. Ten interfejs API przechowuje dane o zdrowiu i samopoczuciu za pomocą subskrypcji. Aplikacja określa co najmniej jeden
typ aktywności do rejestrowania. Google Fit będzie przechowywać w tle dane określonych typów, nawet jeśli aplikacja nie jest uruchomiona. Subskrypcje są też zapisywane po ponownym uruchomieniu systemu.
Rysunek 1. Google Fit na Androidzie
dane historyczne,
Jeśli chcesz, aby użytkownicy mogli wyświetlać dane o aktywności fizycznej z wcześniejszej aktywności, możesz użyć interfejsu History API. Zapewnia on dostęp do historycznych danych o zdrowiu i samopoczuciu oraz umożliwia aplikacjom wykonywanie operacji zbiorczych, takich jak wstawianie, usuwanie i odczytywanie danych.
Sesje
Dane o aktywności fizycznej same w sobie mogą być przydatne, ale w połączeniu z dodatkowymi informacjami o aktywności użytkownika są bardziej przydatne. Interfejs Sessions API łączy dane o zdrowiu i samopoczuciu wraz z metadanymi w jednostki nazywane sesjami. Sesje to przedziały czasu,
w których użytkownik wykonał aktywność fizyczną.
Wyświetl i ustaw cele
Aplikacja może motywować użytkowników, pokazując, jak ich aktywność fizyczna wypada na tle wyznaczonych celów. Goals API pomaga aplikacji wyświetlać użytkownikom cele związane ze zdrowiem i aktywnością fizyczną.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-08-31 UTC."],[[["\u003cp\u003eThe Google Fit APIs let your Android app read, record, and store fitness and wellness data from various sources, including BLE devices.\u003c/p\u003e\n"],["\u003cp\u003eApps can use the Recording API to continuously track user activity in the background, even when the app isn't actively running.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access and manage historical fitness data, enabling users to view past activities and trends through the History API.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Fit allows data to be grouped into sessions, providing context and insights into specific user activities with the Sessions API.\u003c/p\u003e\n"],["\u003cp\u003eApps can leverage the Goals API to display and manage user fitness goals, promoting engagement and motivation.\u003c/p\u003e\n"]]],[],null,["# Android APIs\n\nThe Google Fit APIs for Android are part of [Google Play\nservices](/android/guides/overview). The Google Fit APIs are supported on\nAndroid 4.1 (API level 16) and higher. Using these APIs, your app can do the\nfollowing:\n\n- Read near-real-time and historic data, including data from Bluetooth Low Energy (BLE) devices.\n- Record activities.\n- Associate data with a session.\n- Set fitness goals.\n\nRead sensor data\n----------------\n\nIf your app provides information about a user's activity, such as their daily\nsteps, it can be helpful to show near-real-time data about the user's movements.\nThe [Sensors API](/fit/android/sensors) provides access to streams of raw data\nthat contain this information. The data can come from sensors available on the\nAndroid-powered device as well as from sensors in companion devices, such as\nwearables.\n\nRecord data\n-----------\n\nIf your app needs to gather, store, and sync data about a user's physical\nactivity, you can use the [Recording API](/fit/android/record). This API stores\nhealth and wellness data using subscriptions. Your app specifies one or more\ntypes of activities to record. Google Fit then stores data of the\nspecified types in the background even when your app isn't running. It also\nrestores these subscriptions when the system is restarted. \n**Figure 1.** Google Fit on Android.\n\nHistorical data\n---------------\n\nIf you want users to be able to view fitness data from past activities, you can\nuse the [History API](/fit/android/history). This API provides access to the\nhistorical health and wellness data and lets apps perform bulk operations, such\nas inserting, deleting, and reading data.\n\nSessions\n--------\n\nFitness data can be beneficial by itself, but the data is more useful when you\ncombine it with additional information about the user's activity. The [Sessions\nAPI](/fit/android/using-sessions) bundles health and wellness data, along with\nsome metadata, into units called *sessions*. Sessions represent a time interval\nduring which the user performs a fitness activity.\n\nView and set goals\n------------------\n\nYour app can help motivate users by showing how their fitness activity compares\nto the goals that they've set. The [Goals API](/fit/android/goals) helps your\napp show users the health and fitness goals that they've created."]]