# UserActivityInfo

# UserActivityInfo

Artifact:[androidx.health:health-services-client](https://developer.android.com/jetpack/androidx/releases/health)  
[View Source](https://cs.android.com/search?q=file:androidx/health/services/client/data/UserActivityInfo.kt+class:androidx.health.services.client.data.UserActivityInfo)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/health/services/client/data/UserActivityInfo "View this page in Java")

<br />

```
class UserActivityInfo
```

<br />

*** ** * ** ***

Represents an update from Passive tracking.

Provides[DataPoint](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataPoint)s associated with the Passive tracking, in addition to data related to the user's[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState).

## Summary

|                                              ### Public companion functions                                              |
|--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo) | [createActiveExerciseState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#createActiveExerciseState(androidx.health.services.client.data.ExerciseInfo,java.time.Instant))`(` ` exerciseInfo: `[ExerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseInfo)`,` ` stateChangeTime: `[Instant](https://developer.android.com/reference/java/time/Instant.html) `)` Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_EXERCISE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_EXERCISE()). |
| [UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo) | [createAsleepState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#createAsleepState(java.time.Instant))`(stateChangeTime: `[Instant](https://developer.android.com/reference/java/time/Instant.html)`)` Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_ASLEEP](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_ASLEEP()).                                                                                                                                                                                                                 |
| [UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo) | [createPassiveActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#createPassiveActivityState(java.time.Instant))`(stateChangeTime: `[Instant](https://developer.android.com/reference/java/time/Instant.html)`)` Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_PASSIVE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_PASSIVE()).                                                                                                                                                                                             |
| [UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo) | [createUnknownTypeState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#createUnknownTypeState(java.time.Instant))`(stateChangeTime: `[Instant](https://developer.android.com/reference/java/time/Instant.html)`)` Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_UNKNOWN](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_UNKNOWN()).                                                                                                                                                                                                     |

|                                                                                                                                                                                                                                                                                                                       ### Public constructors                                                                                                                                                                                                                                                                                                                        |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#UserActivityInfo(androidx.health.services.client.data.UserActivityState,androidx.health.services.client.data.ExerciseInfo,java.time.Instant))`(` ` userActivityState: `[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState)`,` ` exerciseInfo: `[ExerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseInfo)`?,` ` stateChangeTime: `[Instant](https://developer.android.com/reference/java/time/Instant.html) `)` |

|                                   ### Public functions                                   |
|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| `open `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [toString](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#toString())`()` |

|                                                   ### Public properties                                                    |
|----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ExerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseInfo)`?`        | [exerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#exerciseInfo()) The[ExerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseInfo)of the user for a[UserActivityState.USER_ACTIVITY_EXERCISE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_EXERCISE())state, and`null`for other[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState)s. |
| [Instant](https://developer.android.com/reference/java/time/Instant.html)                                                  | [stateChangeTime](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#stateChangeTime()) The time at which the current state took effect.                                                                                                                                                                                                                                                                                                                                                                                                              |
| [UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState) | [userActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo#userActivityState()) The[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState)of the user from Passive tracking.                                                                                                                                                                                                                                                                                           |

## Public companion functions

### createActiveExerciseState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
fun createActiveExerciseState(
    exerciseInfo: ExerciseInfo,
    stateChangeTime: Instant
): UserActivityInfo
```

Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_EXERCISE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_EXERCISE()).  

### createAsleepState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
fun createAsleepState(stateChangeTime: Instant): UserActivityInfo
```

Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_ASLEEP](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_ASLEEP()).  

### createPassiveActivityState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
fun createPassiveActivityState(stateChangeTime: Instant): UserActivityInfo
```

Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_PASSIVE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_PASSIVE()).  

### createUnknownTypeState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
fun createUnknownTypeState(stateChangeTime: Instant): UserActivityInfo
```

Creates a[UserActivityInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityInfo)for[USER_ACTIVITY_UNKNOWN](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_UNKNOWN()).  

## Public constructors

### UserActivityInfo

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
UserActivityInfo(
    userActivityState: UserActivityState,
    exerciseInfo: ExerciseInfo?,
    stateChangeTime: Instant
)
```  

## Public functions

### toString

```
open fun toString(): String
```  

## Public properties

### exerciseInfo

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
val exerciseInfo: ExerciseInfo?
```

The[ExerciseInfo](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ExerciseInfo)of the user for a[UserActivityState.USER_ACTIVITY_EXERCISE](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState#USER_ACTIVITY_EXERCISE())state, and`null`for other[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState)s.  

### stateChangeTime

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
val stateChangeTime: Instant
```

The time at which the current state took effect.  

### userActivityState

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/health#1.0.0)  

```
val userActivityState: UserActivityState
```

The[UserActivityState](https://developer.android.com/reference/kotlin/androidx/health/services/client/data/UserActivityState)of the user from Passive tracking.