Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Con l'API Google Awareness, puoi consentire alla tua app di reagire in modo intelligente alla situazione attuale dell'utente. L'API Awareness espone cinque diversi
tipi di contesto, che includono l'attività utente
e i beacon nelle vicinanze. Questi tipi consentono alla tua app di perfezionare l'esperienza utente in modi nuovi che prima non erano possibili. La tua app può combinare questi indicatori di contesto per dedurre la situazione attuale dell'utente e utilizzare queste informazioni per offrire esperienze personalizzate, ad esempio un suggerimento di playlist quando l'utente collega le cuffie e inizia a correre.
Vantaggi dell'API Awareness
L'API Awareness offre diversi vantaggi:
Facilità di implementazione:devi solo aggiungere una singola API alla tua app,
che semplifica notevolmente l'integrazione e migliora la produttività.
Dati di contesto migliori: gli indicatori non elaborati vengono elaborati per migliorare la qualità. Ad esempio, vengono utilizzati algoritmi avanzati per determinare l'attività dell'utente con un elevato livello di accuratezza.
Salute del sistema ottimale: l'API Awareness gestisce automaticamente il proprio impatto sulla durata della batteria e sull'utilizzo dei dati, in modo che la tua app non debba farlo.
Recinti e snapshot
L'API Awareness è composta da due API distinte che la tua app può utilizzare per ottenere indicatori di contesto al fine di determinare la situazione attuale dell'utente:
API Fence: questa API consente alla tua app di reagire alla situazione attuale dell'utente e di inviare una notifica quando viene soddisfatta una combinazione di condizioni di contesto. Ad esempio, ogni volta che l'utente fa una passeggiata e le cuffie sono collegate. Una volta registrato un recinto, l'API Fence può inviare callback alla tua app anche quando non è in esecuzione.
API Snapshot: questa API consente alla tua app di richiedere informazioni sul contesto attuale dell'utente, ad esempio la sua posizione e le condizioni meteo attuali.
Tipi di contesto
Il contesto è il cuore dell'API Awareness. I dati contestuali includono
dati ricavati dai sensori, come la posizione (latitudine e longitudine), il tipo di luogo,
come un parco o un bar, e l'attività, ad esempio una passeggiata o un viaggio in auto. Questi tipi di base o indicatori possono essere combinati per estrapolare la situazione dell'utente in modo più dettagliato. Espandi la seguente notifica per vedere quali indicatori contestuali sono stati ritirati.
Avviso di ritiro: indicatori di contesto di Places e Meteo
La tabella seguente descrive i tipi di contesto di base attualmente offerti dall'API Awareness:
Tipo di contesto
Esempio
Ora
Ora locale corrente
Località
Latitudine e longitudine
Attività
Attività utente rilevate, ad esempio camminata, corsa o ciclismo
Beacon
Beacon nelle vicinanze che corrispondono allo spazio dei nomi specificato
[null,null,["Ultimo aggiornamento 2025-08-31 UTC."],[[["\u003cp\u003eThe Google Awareness API lets your app intelligently respond to the user's context, such as their activity, location, and nearby beacons.\u003c/p\u003e\n"],["\u003cp\u003eIt offers benefits like easy implementation, improved context data quality, and automatic management of system resources.\u003c/p\u003e\n"],["\u003cp\u003eThe API provides two ways to access context: the Fence API for reacting to situations and the Snapshot API for requesting current information.\u003c/p\u003e\n"],["\u003cp\u003eSupported context types include time, location, activity, beacons, and headphone status, while places and weather signals are deprecated.\u003c/p\u003e\n"]]],[],null,["# What's the Awareness API?\n\nWith the Google Awareness API, you can enable your app to intelligently react to the\nuser's current situation. The Awareness API exposes five different\n[context types](#context-types), which include user activity,\nand nearby beacons. These types enable your app to refine the user experience in\nnew ways that weren't possible before. Your app can combine these context\nsignals to make inferences about the user's current situation, and use this\ninformation to provide customized experiences, such as a playlist suggestion\nwhen the user plugs in their headphones and starts to jog.\n\nAwareness API benefits\n----------------------\n\nThe Awareness API provides several benefits:\n\n- **Ease of implementation:** You only need to add a single API to your app, which greatly simplifies integration and improves your productivity.\n- **Better context data:** Raw signals are processed for improved quality. For example, advanced algorithms are used to determine the user's activity with a high level of accuracy.\n- **Optimal system health:** The Awareness API automatically manages its impact on battery life and data usage so that your app doesn't have to.\n\nFences and snapshots\n--------------------\n\nThe Awareness API consists of two distinct APIs that your app can use to\nget context signals in order to determine the user's current situation:\n\n- [**Fence API:**](/awareness/android-api/fence-api-overview) This API lets your app react to the user's current situation, and provides notification when a combination of context conditions are met. For example, whenever the user takes a walk and their headphones are plugged in. Once a fence is registered, the Fence API can send callbacks to your app even when it's not running.\n- [**Snapshot API:**](/awareness/android-api/snapshot-api-overview) This API lets your app request information about the user's current context, such as the user's current location and the current weather conditions.\n\nContext types\n-------------\n\nContext is at the heart of the Awareness API. Contextual data includes\nsensor-derived data such as location (latitude and longitude), place type,\nlike a park or coffee shop, and activity, such as a walk or drive. These basic\ntypes, or signals, can be combined to extrapolate the user's situation in more\nspecific detail. Expand the following notice to see which contextual signals\nhave been deprecated.\n**Deprecation notice: Places and Weather contextual signals** **Warning:**\n| The Places and Weather contextual signals, exposed by the\n| [`getPlaces()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getPlaces()), and\n| [`getWeather()`](/android/reference/com/google/android/gms/awareness/SnapshotClient#getWeather())\n| methods, were deprecated.\n|\n| - The Places contextual signal was turned off. Continued use of this signal was restricted to customers with existing implementations, through October 30, 2019. New implementations must use the [Places SDK for Android](/places/android-sdk) instead of the Places contextual signal.\n| - The Weather contextual signal has also been turned off. Continued use of this signal has been restricted to customers with existing implementations, through January 31, 2020. Google doesn't offer alternative functionality for the Weather contextual signal.\n\nThe following table describes the basic context types currently offered by\nthe Awareness API:\n\n| Context type | Example |\n|--------------|----------------------------------------------------------|\n| Time | Current local time |\n| Location | Latitude and longitude |\n| Activity | Detected user activity, like walking, running, or biking |\n| Beacons | Nearby beacons that match the specified namespace |\n| Headphones | Status of whether headphones are plugged in, or not |"]]