Introduction

Time awareness is used to obtain holiday information in most regions and sunrise and sunset time of all cities around the world.

Barrier API

This API is used to set a timer or a barrier based on the target time. For example, one hour before and after the sunrise can be set as a sunrise barrier.

Capture API

We can use the Capture API to obtains the current local time or time of a specified location, such as working day, weekend, holiday, morning, afternoon, evening, or late at night.

For calling Time Awareness capability we have to assign the given permissions in the manifest file.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

To understand more about Barrier API and Capture API here we are discussing the following two classes:

  • TimeBarrier
  • TimeCategories

Let’s go to the details.

TimeBarrier

This class features barriers to be triggered at a time or periodically based on-time status.

Constants

The below table gives the details of different constants that are commonly used in the TimeBarrierclass.

#java #mobile #integration #kotlin #opensource #hms

Time Awareness: A Journey Through HMS Awareness
1.10 GEEK