DetectedActivity

  • DetectedActivity provides information about the device's activity and the confidence level of that detection.

  • This class includes constants for various detected activity types such as IN_VEHICLE, ON_BICYCLE, ON_FOOT, RUNNING, STILL, TILTING, UNKNOWN, and WALKING.

  • You can get the detected activity type and its confidence level using thegetType() andgetConfidence() methods, respectively.

  • Confidence values range from 0 to 100, with higher values indicating greater likelihood of the detected activity.

public classDetectedActivity extendsObject
implementsParcelable

The detected activity of the device with an an associated confidence. SeeActivityRecognitionApi for details on how to obtain aDetectedActivity.

Constant Summary

int IN_VEHICLEThe device is in a vehicle, such as a car.
int ON_BICYCLEThe device is on a bicycle.
intON_FOOTThe device is on a user who is walking or running.
intRUNNINGThe device is on a user who is running.
intSTILLThe device is still (not moving).
intTILTINGThe device angle relative to gravity changed significantly.
intUNKNOWNUnable to detect the current activity.
intWALKINGThe device is on a user who is walking.

Inherited Constant Summary

From interface android.os.Parcelable
intCONTENTS_FILE_DESCRIPTOR
intPARCELABLE_WRITE_RETURN_VALUE

Field Summary

public static finalCreator<DetectedActivity>CREATOR

Public Constructor Summary

DetectedActivity(int activityType, int confidence)
Constructs a DetectedActivity.

Public Method Summary

int
getConfidence()
Returns a value from 0 to 100 indicating the likelihood that the user is performing this activity.
int
getType()
Returns the type of activity that was detected.
String
void
writeToParcel(Parcel out, int flags)

Inherited Method Summary

From class java.lang.Object
Object
clone()
boolean
equals(Object arg0)
void
finalize()
finalClass<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
From interface android.os.Parcelable
abstract int
describeContents()
abstract void
writeToParcel(Parcel arg0, int arg1)

Constants

public static final intIN_VEHICLE

The device is in a vehicle, such as a car.

Constant Value:0

public static final intON_BICYCLE

The device is on a bicycle.

Constant Value:1

public static final intON_FOOT

The device is on a user who is walking or running.

Constant Value:2

public static final intRUNNING

The device is on a user who is running. This is a sub-activity of ON_FOOT.

Constant Value:8

public static final intSTILL

The device is still (not moving).

Constant Value:3

public static final intTILTING

The device angle relative to gravity changed significantly. This often occurs when a device is picked up from a desk or a user who is sitting stands up.

Constant Value:5

public static final intUNKNOWN

Unable to detect the current activity.

Constant Value:4

public static final intWALKING

The device is on a user who is walking. This is a sub-activity of ON_FOOT.

Constant Value:7

Fields

public static finalCreator<DetectedActivity>CREATOR

Public Constructors

publicDetectedActivity(int activityType, int confidence)

Constructs a DetectedActivity.

Parameters
activityTypethe activity that was detected.
confidencevalue from 0 to 100 indicating how likely it is that the user is performing this activity.

Public Methods

public intgetConfidence()

Returns a value from 0 to 100 indicating the likelihood that the user is performing this activity.

The larger the value, the more consistent the data used to perform the classification is with the detected activity.

This value will be <= 100. It means that larger values indicate that it's likely that the detected activity is correct, while a value of <= 50 indicates that there may be another activity that is just as or more likely.

Multiple activities may have high confidence values. For example, the ON_FOOT may have a confidence of 100 while the RUNNING activity may have a confidence of 95. The sum of the confidences of all detected activities for a classification 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).

public intgetType()

Returns the type of activity that was detected.

publicStringtoString()

public voidwriteToParcel(Parcel out, int flags)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.