Le API Google Fit, inclusa l'API REST di Google Fit, verranno ritirate nel 2026. A partire dal 1° maggio 2024, gli sviluppatori non possono registrarsi per utilizzare queste API.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Le API Google Fit per Android fanno parte dei servizi Google Play. Le API Google Fit sono supportate su Android 4.1 (livello API 16) e versioni successive. Con queste API, la tua app può fare le seguenti operazioni:
Leggi dati storici e quasi in tempo reale, inclusi i dati di dispositivi BLE (Bluetooth LowEnergy).
Registrare le attività.
Associare i dati a una sessione.
Imposta obiettivi di fitness.
Lettura dei dati dei sensori
Se la tua app fornisce informazioni sull'attività di un utente, ad esempio i suoi passi giornalieri, può essere utile mostrare dati quasi in tempo reale sui movimenti dell'utente.
L'API Sensors fornisce l'accesso a flussi di dati non elaborati
contenenti queste informazioni. I dati possono provenire dai sensori disponibili sul dispositivo Android, nonché dai sensori nei dispositivi associati, come gli indossabili.
Registra dati
Se la tua app deve raccogliere, archiviare e sincronizzare i dati sull'attività fisica di un utente, puoi utilizzare l'API Recording. Questa API archivia i dati su salute e benessere utilizzando gli abbonamenti. La tua app specifica uno o più
tipi di attività da registrare. Google Fit memorizza quindi i dati dei tipi specificati in background anche quando la tua app non è in esecuzione. Inoltre, ripristina questi abbonamenti al riavvio del sistema.
Figura 1. Google Fit su Android.
Dati storici
Se vuoi che gli utenti possano visualizzare i dati relativi all'attività fisica di attività passate, puoi
utilizzare l'API History. Questa API consente di accedere ai dati storici su salute e benessere e alle app di eseguire operazioni collettive, come l'inserimento, l'eliminazione e la lettura dei dati.
Sessioni
I dati sull'attività fisica possono essere utili di per sé, ma i dati sono più utili se li combini con informazioni aggiuntive sull'attività dell'utente. L'API Sessions raggruppa i dati su salute e benessere, insieme ad alcuni metadati, in unità chiamate sessioni. Le sessioni rappresentano un intervallo di tempo
durante il quale l'utente esegue un'attività fisica.
Visualizzare e impostare obiettivi
La tua app può motivare gli utenti mostrando la loro attività fisica rispetto agli obiettivi che ti hanno impostato. L'APIGoals consente alla tua app di mostrare agli utenti gli obiettivi di salute e fitness che hanno creato.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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."]]