目录

ActivityIdentificationResponse

Class Info

public class ActivityIdentificationResponse implements Parcelable, IMessageEntity

Activity identification result.

Public Field Summary

Qualifier and Type

Field and Description

static final Creator<ActivityIdentificationResponse>

CREATOR

Used to deserialize the activity identification result.

Public Constructor Summary

Constructor Name

ActivityIdentificationResponse()

Builds an ActivityIdentificationResponse instance.

ActivityIdentificationResponse(ActivityIdentificationData mostActivityIdentificationData, long time, long elapsedTimeFromReboot)

Builds an ActivityIdentificationResponse instance.

ActivityIdentificationResponse(List<ActivityIdentificationData> activityIdentificationDatas, long time, long elapsedTimeFromReboot)

Builds an ActivityIdentificationResponse instance.

Public Method Summary

Qualifier and Type

Method Name and Description

static boolean

containDataFromIntent(Intent intent)

Checks whether the intent contains ActivityIdentificationResponse. If yes, this method will return true.

List<ActivityIdentificationData>

getActivityIdentificationDatas()

Obtains a list of identified activities.

int

getActivityPossibility(int activityType)

Obtains the confidence of the specified activity type.

static ActivityIdentificationResponse

getDataFromIntent(Intent intent)

Obtains ActivityIdentificationResponse from extras of the intent sent by the activity identification service.

long

getElapsedTimeFromReboot()

Obtains the number of milliseconds elapsed since the device boot time to the identification result trigger time.

ActivityIdentificationData

getMostActivityIdentification()

Obtains the most possible activity for the user behavior.

long

getTime()

Obtains the number of milliseconds elapsed since 00:00:00 on January 1, 1970 to the identification result trigger time.

void

setElapsedTimeFromReboot(long elapsedTimeFromReboot)

Sets the number of milliseconds elapsed since the device boot time to the identification result trigger time.

void

setTime(long time)

Sets the number of milliseconds elapsed since 00:00:00 on January 1, 1970 to the identification result trigger time.

Public Fields

[h2]CREATOR

Fields

public static final Creator<ActivityIdentificationResponse> CREATOR

Used to deserialize the activity identification result.

Public Constructors

[h2]ActivityIdentificationResponse

Constructor

public ActivityIdentificationResponse()

Builds an ActivityIdentificationResponse instance.

[h2]ActivityIdentificationResponse(ActivityIdentificationData mostActivityIdentificationData, long time, long elapsedTimeFromReboot)

Constructor

public ActivityIdentificationResponse(ActivityIdentificationData mostActivityIdentificationData, long time, long elapsedTimeFromReboot)

Builds an ActivityIdentificationResponse instance.

Parameters

Name

Description

mostActivityIdentificationData

Most possible activity identified in the period.

time

Number of milliseconds elapsed since 00:00:00 on January 1, 1970.

elapsedTimeFromReboot

Number of milliseconds elapsed since the device boot time to the identification result trigger time.

[h2]ActivityIdentificationResponse(List<ActivityIdentificationData> activityIdentificationDatas, long time, long elapsedTimeFromReboot)

Constructor

public ActivityIdentificationResponse(List<ActivityIdentificationData> activityIdentificationDatas, long time, long elapsedTimeFromReboot)

Builds an ActivityIdentificationResponse instance.

Parameters

Name

Description

activityIdentificationDatas

List of all identified activities in the period, which are sorted by confidence.

time

Number of milliseconds elapsed since 00:00:00 on January 1, 1970.

elapsedTimeFromReboot

Number of nanoseconds elapsed since the device boot time to the identification result trigger time.

Public Methods

[h2]containDataFromIntent

Method

public static boolean containDataFromIntent(Intent intent)

Checks whether the intent contains ActivityIdentificationResponse. If yes, this method will return true. This is a utility function that can be called inside an intent receiver to ensure that the received intent is from the activity identification service.

Parameters

Name

Description

intent

Intent sent by the activity identification service.

Returns

Type

Description

boolean

true if the intent contains ActivityIdentificationResponse; false otherwise.

[h2]getActivityIdentificationDatas

Method

public List<ActivityIdentificationData> getActivityIdentificationDatas()

Obtains a list of identified activities. These activities are sorted by confidence in descending order. The sum of the confidences of all detected activities returned by this method may be greater than 100 because some activities are not mutually exclusive.

Returns

Type

Description

List<ActivityIdentificationData>

List of identified activities.

[h2]getActivityPossibility

Method

public int getActivityPossibility(int activityType)

Obtains the confidence of the specified activity type.

Parameters

Name

Description

activityType

Activity type. For details, please refer to Constant Values.

Returns

Type

Description

int

Confidence.

[h2]getDataFromIntent

Method

public static ActivityIdentificationResponse getDataFromIntent(Intent intent)

Obtains ActivityIdentificationResponse from extras of the intent sent by the activity identification service.

Parameters

Name

Description

intent

Intent sent by the activity identification service.

Returns

Type

Description

ActivityIdentificationResponse

If the intent does not contain ActivityIdentificationResponse, null will be returned.

[h2]getElapsedTimeFromReboot

Method

public long getElapsedTimeFromReboot()

Obtains the number of milliseconds elapsed since the device boot time to the identification result trigger time using SystemClock.elapsedRealtime().

Returns

Type

Description

long

Timestamp, in milliseconds.

[h2]getMostActivityIdentification

Method

public ActivityIdentificationData getMostActivityIdentification()

Obtains the most possible activity for the user behavior.

Returns

Type

Description

ActivityIdentificationData

Most possible activity for the user behavior.

[h2]getTime

Method

public long getTime()

Obtains the number of milliseconds elapsed since 00:00:00 on January 1, 1970 to the identification result trigger time using System.currentTimeMillis().

Returns

Type

Description

long

Timestamp, in milliseconds.

[h2]setElapsedTimeFromReboot

Method

public void setElapsedTimeFromReboot(long elapsedTimeFromReboot)

Sets the number of milliseconds elapsed since the device boot time to the identification result trigger time.

Parameters

Name

Description

elapsedTimeFromReboot

Timestamp, in milliseconds.

[h2]setTime

Method

public void setTime(long time)

Sets the number of milliseconds elapsed since 00:00:00 on January 1, 1970 to the identification result trigger time.

Parameters

Name

Description

time

Timestamp, in milliseconds.