One of the more interesting developments from last year’s Google I/O was the Awareness API. By understanding current context, Android apps can intelligently react based on what’s happening. The API is now being updated with Semantic Time support that automatically handles localization for developers.
The Awareness API consists of two ways for apps to take advantage of signals like location, time, weather, and user activity. A developer can request the context with the Snapshot API, while the Fence API allows an app to react based on a changed signal.
For instance, these signals can be combined to allow a media app to start playing songs when “the user is walking and their headphone is plugged in.”
Google is now expanding the power of this API in regards to how time conditions can be set. It previously required absolute times to be set, with more fluid times — like sunrise and sunset — requiring developers to use a third-party API.
Developers can now have the app and API react based on definitions of time that tend to frequently change, like sunset/sunrise and public holidays. The latter is particularly powerful by allowing developers to just rely on the existing Awareness API to localize times and holidays based on a device’s local settings:
Assume you were a local hiking & adventure app that wants to show users activities they can indulge in on a holiday that falls on a Friday or a Monday. You can use a combination of Days and Holiday flags to identify this state for all your users around the world.
Semantic Time support is available in the Awareness API starting today.
FTC: We use income earning auto affiliate links. More.