class info
public final class TimeBarrier extends Object
Time barriers, including the barriers to be triggered at a time or periodically based on time status.

Constant Summary

TypeNameDesc
intFRIDAY_CODEFriday.
intMONDAY_CODEMonday.
intSATURDAY_CODESaturday.
intSUNDAY_CODESunday.
intTHURSDAY_CODEThursday.
intTUESDAY_CODETuesday.
intWEDNESDAY_CODE
Wednesday.
intSUNRISE_CODEConstant indicating sunrise.
intSUNSET_CODE
Constant indicating sunset.
intTIME_CATEGORY_AFTERNOON
Afternoon time period, that is, 12:00–17:00.
intTIME_CATEGORY_EVENINGEvening time period, that is, 17:00–21:00.
intTIME_CATEGORY_HOLIDAYConstant indicating holidays.
intTIME_CATEGORY_MORNINGMorning time period, that is, 6:00–12:00.
intTIME_CATEGORY_NIGHT
Night time period, that is, 21:00–06:00 (next day).
intTIME_CATEGORY_WEEKDAYConstant indicating workdays.
intTIME_CATEGORY_WEEKENDConstant indicating weekends.
intTIME_CATEGORY_NOT_HOLIDAY
Constant indicating non-holiday dates.

Public Method Summary

Return typeMethod name
AwarenessBarrierpublic static AwarenessBarrier inSunriseOrSunsetPeriod(int timeInstant, long startTimeOffset, long stopTimeOffset)
AwarenessBarrierpublic static AwarenessBarrier duringPeriodOfDay(TimeZone timeZone, long startTimeOfDay, long stopTimeOfDay)
AwarenessBarrierpublic static AwarenessBarrier duringTimePeriod(long startTimeStamp, long stopTimeStamp)
AwarenessBarrierpublic static AwarenessBarrier duringPeriodOfWeek(int dayOfWeek, TimeZone timeZone, long startTimeOfSpecifiedDay, long stopTimeOfSpecifiedDay)
AwarenessBarrierpublic static AwarenessBarrier inTimeCategory(int timeCategory)

Constants

Constant
public static final int FRIDAY_CODE
Friday.
Constant Value: 6
Constant
public static final int MONDAY_CODE
Monday.
Constant Value: 2
Constant
public static final int SATURDAY_CODE
Saturday.
Constant Value: 7
Constant
public static final int SUNDAY_CODE
Sunday.
Constant Value: 1
Constant
public static final int THURSDAY_CODE
Thursday.
Constant Value: 5
Constant
public static final int TUESDAY_CODE
Tuesday.
Constant Value: 3
Constant
public static final int WEDNESDAY_CODE
Wednesday.
Constant Value: 4
Constant
public static final int SUNRISE_CODE
Constant indicating sunrise.
Constant Value: 0
Constant
public static final int SUNSET_CODE
Constant indicating sunset.
Constant Value: 1
Constant
public static final int TIME_CATEGORY_AFTERNOON
Afternoon time period, that is, 12:00–17:00.
Constant Value: 2
Constant
public static final int TIME_CATEGORY_EVENING
Evening time period, that is, 17:00–21:00.
Constant Value: 3
Constant
public static final int TIME_CATEGORY_HOLIDAY
Constant indicating holidays.
Constant Value: 5
Constant
public static final int TIME_CATEGORY_MORNING
Morning time period, that is, 6:00–12:00.
Constant Value: 1
Constant
public static final int TIME_CATEGORY_NIGHT
Night time period, that is, 21:00–06:00 (next day).
Constant Value: 4
Constant
public static final int TIME_CATEGORY_WEEKDAY
Constant indicating workdays.
Constant Value: 6
Constant
public static final int TIME_CATEGORY_WEEKEND
Constant indicating weekends.
Constant Value: 7
Constant
public static final int TIME_CATEGORY_NOT_HOLIDAY
Constant indicating non-holiday dates.
Constant Value: 8

Public Methods

Method
public static AwarenessBarrier inSunriseOrSunsetPeriod(int timeInstant, long startTimeOffset, long stopTimeOffset)
Sunrise and sunset barrier. After this barrier is added, when the time is in the specified time period using the sunrise or sunset time as the benchmark, the barrier status is TRUE. Otherwise, the barrier status is FALSE.
To use this barrier, you need to add the android.permission.ACCESS_FINE_LOCATION permission.

Parameters

Parameter nameParameter desc
timeInstantConstant indicating sunrise or sunset.
SUNRISE_CODE
SUNSET_CODE
startTimeOffsetStart time offset of the time barrier. The unit is millisecond. The value range is milliseconds from –24 hours to +24 hours. The value must be less than the value of stopTimeOffset.
stopTimeOffsetStop time offset of the time barrier. The unit is millisecond. The value range is milliseconds from –24 hours to +24 hours. The value must be greater than the value of startTimeOffset.


Return

Typedesc
AwarenessBarrierAwareness barrier.


Throws

Parameter nameParameter desc
IllegalArgumentExceptionAn unknown or invalid value of timeInstant is passed, the value of startTimeOffset is greater than or equal to the value of stopTimeOffset, or the absolute value of startTimeOffset or stopTimeOffset is greater than the number of milliseconds in 24 hours.
Method
public static AwarenessBarrier duringPeriodOfDay(TimeZone timeZone, long startTimeOfDay, long stopTimeOfDay)
Barrier of a specified time period. After this barrier is added, when the time is in the specified time period of a specified time zone, the barrier status is TRUE. Otherwise, the barrier status is FALSE.
To use this barrier, you need to add the android.permission.ACCESS_FINE_LOCATION permission.

Parameters

Parameter nameParameter desc
timeZoneTime zone specified by you. If the time zone does not exist, the time zone of the area where the user is located is used.
startTimeOfDayStart time of the barrier, in milliseconds. The value 0 indicates 00:00. The maximum value is the number of milliseconds of 24 hours.
stopTimeOfDayStop time of the barrier, in milliseconds. The value of stopTimeOfDay must be greater than or equal to the value of startTimeOfDay.


Return

Typedesc
AwarenessBarrierAwareness barrier.


Throws

Parameter nameParameter desc
IllegalArgumentExceptionThe value of startTimeofDay is greater than that of stopTimeofDay, or the value of startTimeofDay or stopTimeofDay is negative, or greater than the number of milliseconds in 24 hours.
Method
public static AwarenessBarrier duringTimePeriod(long startTimeStamp, long stopTimeStamp)
Time period barrier. After this barrier is added, when the time is in the specified time period, the barrier status is TRUE. Otherwise, the barrier status is FALSE.

Parameters

Parameter nameParameter desc
startTimeStampStart timestamp. The value must be greater than or equal to 0.
stopTimeStampStop timestamp. The value of stopTimeStamp must be greater than or equal to that of startTimeStamp.


Return

Typedesc
AwarenessBarrierAwareness barrier.


Throws

Parameter nameParameter desc
IllegalArgumentExceptionThe value of startTimeStamp is greater than that of stopTimeStamp, or the value of startTimeStamp or stopTimeStamp is negative.
Method
public static AwarenessBarrier duringPeriodOfWeek(int dayOfWeek, TimeZone timeZone, long startTimeOfSpecifiedDay, long stopTimeOfSpecifiedDay)
Barrier for a specific day of a week. After this barrier is added, when the time is in the specified time period on a day of a week in a specified time zone, the barrier status is TRUE. Otherwise, the barrier status is FALSE.
To use this barrier, you need to add the android.permission.ACCESS_FINE_LOCATION permission.

Parameters

Parameter nameParameter desc
dayOfWeekDay of a week. The options are as follows: SUNDAY_CODE, MONDAY_CODE, TUESDAY_CODE, WEDNESDAY_CODE, THURSDAY_CODE, FRIDAY_CODE, and SATURDAY_CODE.
timeZoneTime zone specified by you. If the time zone does not exist, the time zone of the area where the user is located is used.
startTimeOfSpecifiedDayStart time of the barrier, in milliseconds. The value 0 indicates 00:00. The maximum value is the number of milliseconds of 24 hours.
stopTimeOfSpecifiedDayStop time of the barrier, in milliseconds. The value of stopTimeOfSpecifiedDay must be greater than or equal to the value of startTimeOfSpecifiedDay.


Return

Typedesc
AwarenessBarrierAwareness barrier.


Throws

Parameter nameParameter desc
IllegalArgumentExceptionThe value of dayOfWeek is incorrect, the value of startTimeOfSpecifiedDay is greater than that of stopTimeOfSpecifiedDay, or the values of startTimeOfSpecifiedDay and stopTimeOfSpecifiedDay are negative or greater than the number of milliseconds in 24 hours.
Method
public static AwarenessBarrier inTimeCategory(int timeCategory)
Time status barrier. After this barrier is added, when the time is in the specified time state, the barrier status is TRUE. Otherwise, the barrier status is FALSE.
To use this barrier, you need to add the android.permission.ACCESS_FINE_LOCATION permission.

Parameters

Parameter nameParameter desc
timeCategoryTime status constant. The options are as follows: TIME_CATEGORY_MORNING, TIME_CATEGORY_AFTERNOON, TIME_CATEGORY_EVENING, TIME_CATEGORY_NIGHT, TIME_CATEGORY_WEEKDAY, TIME_CATEGORY_WEEKEND,  TIME_CATEGORY_HOLIDAY,andTIME_CATEGORY_NOT_HOLIDAY (non-holiday date).


Return

Typedesc
AwarenessBarrierAwareness barrier.


Throws

Parameter nameParameter desc
IllegalArgumentExceptionAn unknown or invalid value of timeCategory is passed.