public class

ActivityRecognitionResult

extends Object
implements Parcelable Parcelable
java.lang.Object
   ↳ com.google.android.gms.location.ActivityRecognitionResult

Class Overview

Result of an activity recognition.

It contains a list of activities that a user may have been doing at a particular time. The activities are sorted by the most probable activity first. A confidence is associated with each activity which indicates how likely that activity is.

getMostProbableActivity() will return the most probable activity of the user at the time that activity recognition was run.

Summary

[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<ActivityRecognitionResult> CREATOR
Public Constructors
ActivityRecognitionResult(List<DetectedActivity> probableActivities, long time, long elapsedRealtimeMillis)
Constructs an ActivityRecognitionResult.
ActivityRecognitionResult(DetectedActivity mostProbableActivity, long time, long elapsedRealtimeMillis)
Constructs an ActivityRecognitionResult from a single activity.
Public Methods
static ActivityRecognitionResult extractResult(Intent intent)
Extracts the ActivityRecognitionResult from an Intent.
int getActivityConfidence(int activityType)
Returns the confidence of the given activity type.
long getElapsedRealtimeMillis()
Returns the elapsed real time of this detection in milliseconds since boot, including time spent in sleep as obtained by SystemClock.elapsedRealtime().
DetectedActivity getMostProbableActivity()
Returns the most probable activity of the user.
List<DetectedActivity> getProbableActivities()
Returns the list of activities that were detected with the confidence value associated with each activity.
long getTime()
Returns the UTC time of this detection, in milliseconds since January 1, 1970.
static boolean hasResult(Intent intent)
Returns true if an Intent contains an ActivityRecognitionResult.
String toString()
void writeToParcel(Parcel out, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Fields

public static final Creator<ActivityRecognitionResult> CREATOR

Public Constructors

public ActivityRecognitionResult (List<DetectedActivity> probableActivities, long time, long elapsedRealtimeMillis)

Constructs an ActivityRecognitionResult.

Parameters
probableActivities List: the activities that were detected, sorted by confidence (most probable first).
time long: the UTC time of this detection, in milliseconds since January 1, 1970.
elapsedRealtimeMillis long: milliseconds since boot

public ActivityRecognitionResult (DetectedActivity mostProbableActivity, long time, long elapsedRealtimeMillis)

Constructs an ActivityRecognitionResult from a single activity.

Parameters
mostProbableActivity DetectedActivity: the most probable activity of the device.
time long: the UTC time of this detection, in milliseconds since January 1, 1970.
elapsedRealtimeMillis long: milliseconds since boot.

Public Methods

public static ActivityRecognitionResult extractResult (Intent intent)

Extracts the ActivityRecognitionResult from an Intent.

This is a utility function which extracts the ActivityRecognitionResult from the extras of an Intent that was sent from the activity detection service.

Parameters
intent Intent
Returns
ActivityRecognitionResult an ActivityRecognitionResult, or null if the intent doesn't contain an ActivityRecognitionResult.

public int getActivityConfidence (int activityType)

Returns the confidence of the given activity type.

Parameters
activityType int
Returns
int

public long getElapsedRealtimeMillis ()

Returns the elapsed real time of this detection in milliseconds since boot, including time spent in sleep as obtained by SystemClock.elapsedRealtime().

Returns
long

public DetectedActivity getMostProbableActivity ()

Returns the most probable activity of the user.

Returns
DetectedActivity

public List<DetectedActivity> getProbableActivities ()

Returns the list of activities that were detected with the confidence value associated with each activity. The activities are sorted by most probable activity first.

The sum of the confidences of all detected activities this method returns does not have to be <= 100 since some activities are not mutually exclusive (for example, you can be walking while in a bus) and some activities are hierarchical (ON_FOOT is a generalization of WALKING and RUNNING).

Returns
List<DetectedActivity>

public long getTime ()

Returns the UTC time of this detection, in milliseconds since January 1, 1970.

Returns
long

public static boolean hasResult (Intent intent)

Returns true if an Intent contains an ActivityRecognitionResult.

This is a utility function that can be called from inside an intent receiver to make sure the received intent is from activity recognition.

Parameters
intent Intent
Returns
boolean true if the intent contains an ActivityRecognitionResult, false otherwise or the given intent is null

public String toString ()

Returns
String

public void writeToParcel (Parcel out, int flags)

Parameters
out Parcel
flags int