Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

close

- - Get Started
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
    - Get the SDK
  - Google Services
- - Google Play
  - Publishing
  - Promoting
  - App Quality
  - Spotlight
  - Open Distribution

## Results

Loading...
Summary: Constants | Inherited Constants | Fields | Ctors | Methods | Inherited Methods | [Expand All]
public class

# ActivityRecognitionResult

extends Object
implements 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

Constants
String | EXTRA_ACTIVITY_RESULT |

[Expand] Inherited Constants

From interface android.os.Parcelable

int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final ActivityRecognitionResultCreator | 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
int | describeContents()
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 where 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

Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)

From interface android.os.Parcelable

abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final String EXTRA_ACTIVITY_RESULT

Constant Value: "com.google.android.location.internal.EXTRA_ACTIVITY_RESULT"

## Fields

#### public static final ActivityRecognitionResultCreator CREATOR

## Public Constructors

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

Constructs an ActivityRecognitionResult.

##### Parameters

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

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

Constructs an ActivityRecognitionResult from a single activity.

##### Parameters

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

## Public Methods

#### public int describeContents ()

#### 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.

##### Returns

- 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.

#### 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().

#### public DetectedActivity getMostProbableActivity ()

Returns the most probable activity of the user.

#### public List<DetectedActivity> getProbableActivities ()

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

The sum of confidence values for the activities is guaranteed to be <= 100.

#### public long getTime ()

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

#### 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.

##### Returns

- true if the intent contains an ActivityRecognitionResult, false otherwise.

#### public String toString ()

#### public void writeToParcel (Parcel out, int flags)