目录

interface info
public interface CaptureClient
Main entry of capture APIs of HUAWEI Awareness Kit to obtain the headset status, behavior, time, location, beacon status, ambient light, weather, Bluetooth car kit connection status, and capability support status.

Public Method Summary

Task<TimeCategoriesResponse>

Return type
Method name

Task<BeaconStatusResponse>

getBeaconStatus(BeaconStatus.Filter… filters)

Task<BeaconStatusResponse>

getBeaconStatus(Collection<BeaconStatus.Filter> filters)

Task<BehaviorResponse>

getBehavior()

Task<HeadsetStatusResponse>

getHeadsetStatus()

Task<LocationResponse>

getLocation()

Task<LocationResponse>

getCurrentLocation()

Task<TimeCategoriesResponse>

getTimeCategories()

Task<TimeCategoriesResponse>

getTimeCategoriesByUser(double latitude, double longitude)

Task<TimeCategoriesResponse>

getTimeCategoriesByCountryCode(String countryCode)

Task<TimeCategoriesResponse>

getTimeCategoriesByIP()

Task<TimeCategoriesResponse>

getTimeCategoriesForFuture(long futureTimestamp)

Task<AmbientLightResponse>

getLightIntensity()

Task<WeatherStatusResponse>

getWeatherByDevice()

Task<WeatherStatusResponse>

getWeatherByIP()

Task<WeatherStatusResponse>

getWeatherByPosition(WeatherPosition position)

Task<BluetoothStatusResponse>

getBluetoothStatus(int deviceType)

Task<CapabilityResponse>

querySupportingCapabilities()

void

enableUpdateWindow(boolean isEnable)

Public Methods

Method
public abstract Task<BeaconStatusResponse> getBeaconStatus(BeaconStatus.Filter... filters)
Use a variable number of the filters parameters to get information about related beacons.
Note that the beacon capture function is available only on devices with API level 24 or later. To use this method, your app must declare the android.permission.BLUETOOTH and android.permission.ACCESS_FINE_LOCATION permissions in AndroidManifest.xml, and users must choose to agree during app running.

Parameters

Parameter nameParameter desc
filtersBeacon filter, which can be constructed in either of the following methods:1. filter data by beacon namespace and type2. filter data by beacon namespace, type, and content


Return

Typedesc
Task<BeaconStatusResponse>Generics of Task in BeaconStatusResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the beacon data can be obtained through BeaconStatusResponse. Otherwise, the beacon information fails to be obtained.
Method
public abstract Task<BeaconStatusResponse> getBeaconStatus(Collection<BeaconStatus.Filter> filters)
Passes a set of filterss as parameters to get the information about related beacons.
Note that the beacon capture function is available only on devices with API level 24 or later. To use this method, your app must declare the android.permission.BLUETOOTH and android.permission.ACCESS_FINE_LOCATION permissions in AndroidManifest.xml, and users must choose to agree during app running.

Parameters

Parameter nameParameter desc
filtersBeacon filter, which can be constructed in either of the following methods:1. filter data by beacon namespace and type2. filter data by beacon namespace, type, and content

Return

Typedesc
Task<BeaconStatusResponse>Generics of Task in BeaconStatusResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the beacon data can be obtained through BeaconStatusResponse. Otherwise, the beacon information fails to be obtained.
Method
public abstract Task<BehaviorResponse> getBehavior()
Gets current behavior status of a user, for example, running, walking, cycling, or driving.
To call this function, your app needs different permissions, depending on your Android API level. For Android 10 (API level 29) and later versions, your app needs to declare the android.permission.ACTIVITY_RECOGNITION permission.
For Android 9 (API level 28) and earlier versions, your app needs to declare the com.huawei.hms.permission.ACTIVITY_RECOGNITION permission.

Return

Typedesc
Task<BehaviorResponse>Generics of Task in BehaviorResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current user behavior data can be obtained through BehaviorResponse. Otherwise, current user behavior information fails to be obtained.
Method
public abstract Task<HeadsetStatusResponse> getHeadsetStatus()
Gets the headset connection status.
Note: This method is available only to devices whose Android API level is 24 or higher.

Return

Typedesc

Task<HeadsetStatusResponse>

Generics of Task in HeadsetStatusResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the current headset connection status can be obtained through HeadsetStatusResponse. Otherwise, the headset connection status fails to be obtained.
Method
public abstract Task<LocationResponse> getLocation()
Obtains location information (latitude/longitude) of a device. The location information obtained by using this method is the value queried last time and cached on the device.
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and users must choose to agree during app running.

Return

Typedesc
Task<LocationResponse>Generics of Task in LocationResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the current device location data can be obtained through LocationResponse. Otherwise, the location information fails to be obtained.
Method
public abstract Task<LocationResponse> getCurrentLocation()
Re-obtains the latest device location information (latitude/longitude). When this method is used to obtain the location information, the system obtains the location information again based on the current location of the device, returns the location information, and updates the location information cached on the device.
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and users must choose to agree during app running.

Return

Typedesc
Task<LocationResponse>Generics of Task in LocationResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the current device location data can be obtained through LocationResponse. Otherwise, the location information fails to be obtained.
Method
public abstract Task<TimeCategoriesResponse> getTimeCategories()
Gets current time status. The time status includes the following defined in the TimeBarrier class: TIME_CATEGORY_MORNING (morning), TIME_CATEGORY_AFTERNOON (afternoon), TIME_CATEGORY_EVENING (evening), TIME_CATEGORY_NIGHT (night), TIME_CATEGORY_WEEKDAY (weekday), TIME_CATEGORY_WEEKEND (weekend), TIME_CATEGORY_HOLIDAY (holiday), and TIME_CATEGORY_NOT_HOLIDAY (non-holiday date).
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml and users must choose to agree during app running.

Return

Typedesc
Task<TimeCategoriesResponse>Generics of Task in TimeCategoriesResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current time status can be obtained through TimeCategoriesResponse. Otherwise, time status fails to be obtained.
Method
public abstract Task<TimeCategoriesResponse> getTimeCategoriesByUser(double latitude, double longitude)
Obtains the current time status of a specified location. The time status includes the following defined in the TimeBarrier class: TIME_CATEGORY_MORNING (morning), TIME_CATEGORY_AFTERNOON (afternoon), TIME_CATEGORY_EVENING (evening), TIME_CATEGORY_NIGHT (night), TIME_CATEGORY_WEEKDAY (weekday), TIME_CATEGORY_WEEKEND (weekend), TIME_CATEGORY_HOLIDAY (holiday), and TIME_CATEGORY_NOT_HOLIDAY (non-holiday date).
Note: This method is available only to devices whose Android API level is 24 or higher.

Parameters

Parameter nameParameter desc
latitudeLatitude.
longitudeLongitude.

Return

Typedesc
Task<TimeCategoriesResponse>Generics of Task in TimeCategoriesResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current time status can be obtained through TimeCategoriesResponse. Otherwise, time status fails to be obtained.
Method
public abstract Task<TimeCategoriesResponse> getTimeCategoriesByCountryCode(String countryCode)
Obtains the current time status by country/region code that complies with ISO 3166-1 alpha-2. When this method is used, the time status and time zone information of the capital is returned, even if the country is covered by multiple time zones.
The time status includes the following defined in the TimeBarrier class: TIME_CATEGORY_MORNING (morning), TIME_CATEGORY_AFTERNOON (afternoon), TIME_CATEGORY_EVENING (evening), TIME_CATEGORY_NIGHT (night), TIME_CATEGORY_WEEKDAY (weekday), TIME_CATEGORY_WEEKEND (weekend), TIME_CATEGORY_HOLIDAY (holiday), and TIME_CATEGORY_NOT_HOLIDAY (non-holiday date).
Note: This method is available only to devices whose Android API level is 24 or higher.

Parameters

Parameter nameParameter desc
countryCodeCountry/Region code that complies with ISO 3166-1 alpha-2.

Return

Typedesc
Task<TimeCategoriesResponse>Generics of Task in TimeCategoriesResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current time status can be obtained through TimeCategoriesResponse. Otherwise, time status fails to be obtained.
Method
public abstract Task<TimeCategoriesResponse> getTimeCategoriesByIP()
Obtains the current time status by IP address. When this method is used, the time status of the location corresponding to the IP address is returned. Note that the result returned through this method is less accurate than that returned through getTimeCategories, but this method does not require the precise location permission. You can select a method based on your actual requirements.
The time status includes the following defined in the TimeBarrier class: TIME_CATEGORY_MORNING (morning), TIME_CATEGORY_AFTERNOON (afternoon), TIME_CATEGORY_EVENING (evening), TIME_CATEGORY_NIGHT (night), TIME_CATEGORY_WEEKDAY (weekday), TIME_CATEGORY_WEEKEND (weekend), TIME_CATEGORY_HOLIDAY (holiday), and TIME_CATEGORY_NOT_HOLIDAY (non-holiday date).
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_COARSE_LOCATION permission in AndroidManifest.xml.

Return

Typedesc
Task<TimeCategoriesResponse>Generics of Task in TimeCategoriesResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current time status can be obtained through TimeCategoriesResponse. Otherwise, time status fails to be obtained.
Method
public abstract Task<TimeCategoriesResponse> getTimeCategoriesForFuture(long futureTimestamp)
Obtains the time status of a specified date by IP address. You can specify a future date and use this method to query its time status. Note that cross-year query is not supported.
The time status includes the following defined in the TimeBarrier class: TIME_CATEGORY_MORNING (morning), TIME_CATEGORY_AFTERNOON (afternoon), TIME_CATEGORY_EVENING (evening), TIME_CATEGORY_NIGHT (night), TIME_CATEGORY_WEEKDAY (weekday), TIME_CATEGORY_WEEKEND (weekend), TIME_CATEGORY_HOLIDAY (holiday), and TIME_CATEGORY_NOT_HOLIDAY (non-holiday date).
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_COARSE_LOCATION permission in AndroidManifest.xml.

Parameters

Parameter nameParameter desc
futureTimestampTimestamp of the specified date. You can only set this parameter to a timestamp in the current year, because cross-year query is not supported. The timestamp is the total number of milliseconds from 00:00:00 on January 1, 1970 (GMT) to the current time.

Return

Typedesc
Task<TimeCategoriesResponse>Generics of Task in TimeCategoriesResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, current time status can be obtained through TimeCategoriesResponse. Otherwise, time status fails to be obtained.
Method
public abstract Task<AmbientLightResponse> getLightIntensity()
Obtains the illuminance.
Note: This method is available only to devices whose Android API level is 24 or higher.

Return

Typedesc
Task<AmbientLightResponse>Returns the generics of Task in AmbientLightResponse. The value of AmbientLightResponse can be obtained from AmbientLightResponse.
Method
public abstract Task<WeatherStatusResponse> getWeatherByDevice()

Obtains the weather of the current location of a device.

Due to system restrictions, the total number of capture API calls every 5 seconds cannot exceed 20, and the total number of capture API calls every hour cannot exceed 1000. Therefore, if the call frequency exceeds the threshold, a failure message is returned for weather capture API calls.

Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION permission in AndroidManifest.xml, and users must choose to agree before app running.

Return

Typedesc
Task<WeatherStatusResponse>Returns the generics of Task in WeatherStatusResponse. You can call getWeatherStatus in WeatherStatusResponse to obtain the value of WeatherStatus, which carries the weather information about the current location of the device.
Method
public abstract Task<WeatherStatusResponse> getWeatherByIP()

Obtains the weather status response by IP address.

Due to system restrictions, the total number of capture API calls every 5 seconds cannot exceed 20, and the total number of capture API calls every hour cannot exceed 1000. Therefore, if the call frequency exceeds the threshold, a failure message is returned for weather capture API calls.

Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.ACCESS_COARSE_LOCATION permission in AndroidManifest.xml.

Return

Typedesc
Task<WeatherStatusResponse>Generics of Task in WeatherStatusResponse. You can call getWeatherStatus in WeatherStatusResponse to obtain the value of WeatherStatus, which carries the weather information about the current location of the device.
Method
public abstract Task<WeatherStatusResponse> getWeatherByPosition(WeatherPosition position)

Obtains weather information about a specified address.

Due to system restrictions, the total number of capture API calls every 5 seconds cannot exceed 20, and the total number of capture API calls every hour cannot exceed 1000. Therefore, if the call frequency exceeds the threshold, a failure message is returned for weather capture API calls.

An address has five attributes: country, province, city, district, and county. The city must be set and other four attributes are optional. It is recommended that all attributes be specified to constitute an accurate address so that the returned weather information will be more accurate. When entering an address, you need to specify the language type of the address. The system returns the weather information in the corresponding language based on the language type.
For example, you can enter London, or England, London, and then specify en_GB as the locale to obtain the weather of London.
Note: This method is available only to devices whose Android API level is 24 or higher.

Parameters

Parameter nameParameter desc
positionAddress information for weather query, including the address and language type.An address consists of the country, province, city, district, and county. You do not need to pass all of the five attributes but can combine any of them as required. For example, if you want to query the weather of London, you can pass only the city attribute London or both the country attribute UK and city attribute London.The language type is of the locale format. For example, en_GB indicates British English. Note that the language type is mandatory and must meet the locale format language code_country/region code.

Return

Typedesc
Task<WeatherStatusResponse>Generics of Task in WeatherStatusResponse. You can call getWeatherStatus in WeatherStatusResponse to obtain the value of WeatherStatus, which carries the weather information about a specified location.
Method
public abstract Task<BluetoothStatusResponse> getBluetoothStatus(int deviceType)
Obtains the Bluetooth car kit connection status.
Note: This method is available only to devices whose Android API level is 24 or higher. To use this method, your app must declare the android.permission.BLUETOOTH permission in AndroidManifest.xml.

Parameters

Parameter nameParameter desc
deviceTypeBluetooth device type.Value 0 indicates a Bluetooth car kit.

Return

Typedesc

Task<BluetoothStatusResponse>

Generics of Task in BluetoothStatusResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the connection status of the current Bluetooth car kit can be obtained through BluetoothStatusResponse. Otherwise, the connection status fails to be obtained.
Method
public abstract Task<CapabilityResponse> querySupportingCapabilities()
Obtains capabilities supported by Awareness Kit on the current device.

Return

Task<CapabilityResponse>Typedesc
Task<CapabilityResponse>Generics of Task in CapabilityResponse. You can use isSuccessful() in Task to check whether the operation is successful. If the operation is successful, the capabilities supported by the current device can be obtained through CapabilityResponse. Otherwise, the capabilities fail to be obtained.
Method
public void enableUpdateWindow(boolean isEnable)

Indicates whether to display a dialog box when Awareness Kit and HMS Core are upgraded.

Note: Excise precaution when using this method. If you determine not to display such a dialog box, no upgrade will be performed, because not displaying the dialog box has the same effect as selecting Cancel in the dialog box if it appears. All functions of Awareness Kit will be unavailable before its upgrade is complete. In this case, wait for a silent upgrade, which generally occurs every 7 to 14 days. The functions will be resumed after a silent upgrade is complete.