# Status

# Status

Artifact:[androidx.wear:wear-ongoing](https://developer.android.com/jetpack/androidx/releases/wear)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/ongoing/Status.java+class:androidx.wear.ongoing.Status)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/wear#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/ongoing/Status "View this page in Java")

<br />

```
class Status : TimeDependentText
```

<br />

*** ** * ** ***

Base class to represent the status of an Ongoing Activity and render it.

A status is composed of Parts, and they are joined together with a template.

Note that for backwards compatibility reasons the code rendering this status message may not have all of the \[Part\] classes that are available in later versions of the library. Templates that do not have values for all of the named parts will not be used. The template list will be iterated through looking for the first template with all matching named parts available, this will be selected for rendering the status.

To provide for backwards compatibility, you should provide one (or more) fallback templates which use status parts from earlier versions of the API. e.g. TextPart, TimerPart \&StopwatchPart

The status and part classes here use timestamps for updating the displayed representation of the status, in cases when this is needed (chronometers), as returned by[elapsedRealtime](https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime())

## Summary

|                                                                                                                                                                                                                                                                          ### Nested types                                                                                                                                                                                                                                                                           |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[Status.Builder](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Builder) Helper to Build OngoingActivityStatus instances.                                                                                                                                                                                                                                                                                                                                                                                                      |
| `abstract class `[Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part)` : `[TimeDependentText](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/TimeDependentText) Abstract class to represent An Ongoing activity status or part of it.                                                                                                                                                                                                                                                              |
| `class `[Status.StopwatchPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.StopwatchPart)` : `[Status.TimerOrStopwatchPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TimerOrStopwatchPart) An Ongoing activity status (or part of it) representing a stopwatch                                                                                                                                                                                                                                   |
| `class `[Status.TextPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TextPart)` : `[Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part) An Ongoing activity status (or part of it) representing a plain, static text.                                                                                                                                                                                                                                                                   |
| `abstract class `[Status.TimerOrStopwatchPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TimerOrStopwatchPart)` : `[Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part) Base class for[TimerPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TimerPart)and[StopwatchPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.StopwatchPart), defines the getters but can't be created directly, create one of those instead. |
| `class `[Status.TimerPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TimerPart)` : `[Status.TimerOrStopwatchPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.TimerOrStopwatchPart) An Ongoing activity status (or part of it) representing a timer.                                                                                                                                                                                                                                              |

|                                                                                                                                           ### Public functions                                                                                                                                           |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Status](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status)                                                                                                                                                                                                      | [forPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#forPart(androidx.wear.ongoing.Status.Part))`(part: `[Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part)`)` Convenience method for creating a Status with no template and a single Part.                                                                     |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                                                                                                                                                            | [getNextChangeTimeMillis](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#getNextChangeTimeMillis(long))`(fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns the next time this status could have a different rendering.                                                                                   |
| [Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part)`?`                                                                                                                                                                                                       | [getPart](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#getPart(java.lang.String))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Returns the value of the part with the given name.                                                                                                                              |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)`)`[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>`                 | [getPartNames](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#getPartNames())`()`                                                                                                                                                                                                                                                                                |
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!>` | [getTemplates](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#getTemplates())`()`                                                                                                                                                                                                                                                                                |
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)                                                                                                                                                                                                           | [getText](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status#getText(android.content.Context,long))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, timeNowMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns a textual representation of this status at the given time. |

## Public functions

### forPart

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

```
java-static fun forPart(part: Status.Part): Status
```

Convenience method for creating a Status with no template and a single Part.  

|                                               Parameters                                                |
|---------------------------------------------------------------------------------------------------------|------------------------------------------|
| `part: `[Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part) | The only Part that composes this status. |

|                                        Returns                                        |
|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| [Status](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status) | A new[Status](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status)with just one Part. |

### getNextChangeTimeMillis

```
fun getNextChangeTimeMillis(fromTimeMillis: Long): Long
```

Returns the next time this status could have a different rendering. There is no guarantee that the rendering will change at the returned time (for example, if some information in the status is not rendered).  

|                                           Parameters                                            |
|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `fromTimeMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | current time, usually now as returned by[elapsedRealtime](https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()). In most cases`getText`and`getNextChangeTimeMillis`should be called with the exact same timestamp, so changes are not missed. |

|                                    Returns                                    |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | the next time (counting from fromTimeMillis) that this status may produce a different result when calling getText(). |

### getPart

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

```
fun getPart(name: String): Status.Part?
```

Returns the value of the part with the given name.  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|---------------------|
| `name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the name to lookup. |

|                                              Returns                                               |
|----------------------------------------------------------------------------------------------------|--------------------------------------------|
| [Status.Part](https://developer.android.com/reference/kotlin/androidx/wear/ongoing/Status.Part)`?` | the part with the given name, can be null. |

### getPartNames

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

```
fun getPartNames(): (Mutable)Set<String!>
```  

|                                                                                                                                         Returns                                                                                                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)`)`[Set](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html)`<`[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!>` | the names of the parts provide to this status. |

### getTemplates

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

```
fun getTemplates(): (Mutable)List<CharSequence!>
```  

|                                                                                                                                                 Returns                                                                                                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`!>` | the list of templates that this status has. |

### getText

```
fun getText(context: Context, timeNowMillis: Long): CharSequence
```

Returns a textual representation of this status at the given time. The first template that has all required information will be used, and each part will be used in their respective placeholder/s.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)     | may be used for internationalization. Only used while this method executed. |
| `timeNowMillis: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | the timestamp of the time we want to display, usually now, as               |

|                                            Returns                                             |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html) | the rendered text, for best compatibility, display using a TextView. |