Android 12 Developer Preview is here! Try it out, and give us your feedback!

OngoingActivityStatus.Builder

public static final class OngoingActivityStatus.Builder
extends Object

java.lang.Object
   ↳ androidx.wear.ongoing.OngoingActivityStatus.Builder


Helper to Build OngoingActivityStatus instances. Templates can be specified, to specify how to render the parts and any surrounding text/format. If no template is specified, a default template that concatenates all parts separated by space is used.

Summary

Public constructors

Builder()

Public methods

OngoingActivityStatus.Builder addPart(String name, StatusPart part)

Add a part to be inserted in the placeholders.

OngoingActivityStatus.Builder addTemplate(CharSequence template)

Add a template to use for this status.

OngoingActivityStatus build()

Build an OngoingActivityStatus with the given parameters.

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

addPart

public OngoingActivityStatus.Builder addPart (String name, 
                StatusPart part)

Add a part to be inserted in the placeholders.

Parameters
name String: the name of this part. In the template, use this name surrounded by '#' to reference it, e.g. here "track" and in the template "#track#"

part StatusPart: The part that will be rendered in the specified position/s in the template.

Returns
OngoingActivityStatus.Builder this builder, to chain calls.

addTemplate

public OngoingActivityStatus.Builder addTemplate (CharSequence template)

Add a template to use for this status. Placeholders can be defined with #name# To produce a '#', use '##' in the template. If multiple templates are specified, the first one (in the order they where added by calling this method) that has all required fields is used. If no template is specified, a default template that concatenates all parts separated by space is used.

Parameters
template CharSequence: the template to be added

Returns
OngoingActivityStatus.Builder this builder, to chain calls.

build

public OngoingActivityStatus build ()

Build an OngoingActivityStatus with the given parameters.

Returns
OngoingActivityStatus the built OngoingActivityStatus