public final class

OngoingActivity.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.wear.ongoing.OngoingActivity.Builder

Overview

Builder used to build an OngoingActivity

Note that many fields take a default value from the provided notification if not explicitly set. If set explicitly and in the notification, the value set through the OngoingActivity.Builder will be used.

The only required fields (set through the builder or the notification) are static icon and pending intent.

Summary

Constructors
publicBuilder(Context context, int notificationId, NotificationCompat.Builder notificationBuilder)

Construct a new empty OngoingActivity.Builder, associated with the given notification.

publicBuilder(Context context, java.lang.String tag, int notificationId, NotificationCompat.Builder notificationBuilder)

Construct a new empty OngoingActivity.Builder, associated with the given notification.

Methods
public OngoingActivitybuild()

Combine all options provided and the information in the notification if needed, return a new OngoingActivity object.

public OngoingActivity.BuildersetAnimatedIcon(Icon animatedIcon)

Set the animated icon that can be used on some surfaces to represent this OngoingActivity.

public OngoingActivity.BuildersetCategory(java.lang.String category)

Set the category of this OngoingActivity.

public OngoingActivity.BuildersetLocusId(LocusIdCompat locusId)

Set the corresponding LocusId of this OngoingActivity, this will be used by the launcher to identify the corresponding launcher item and display it accordingly.

public OngoingActivity.BuildersetOngoingActivityId(int ongoingActivityId)

Give an id to this OngoingActivity, as a way to reference it in OngoingActivity.recoverOngoingActivity(Context, int)

public OngoingActivity.BuildersetStaticIcon(Icon staticIcon)

Set the static icon that can be used on some surfaces to represent this OngoingActivity, for example in the WatchFace in ambient mode.

public OngoingActivity.BuildersetStatus(Status status)

Set the initial status of this ongoing activity, the status may be displayed on the UI to show progress of the Ongoing Activity.

public OngoingActivity.BuildersetTitle(java.lang.String title)

Sets the Title of this OngoingActivity.

public OngoingActivity.BuildersetTouchIntent(PendingIntent touchIntent)

Set the intent to be used to go back to the activity when the user interacts with the Ongoing Activity in other surfaces (for example, taps the Icon on the WatchFace).

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context, int notificationId, NotificationCompat.Builder notificationBuilder)

Construct a new empty OngoingActivity.Builder, associated with the given notification.

Parameters:

context: to be used during the life of this OngoingActivity.Builder, will NOT pass a reference into the built OngoingActivity
notificationId: id that will be used to post the notification associated with this Ongoing Activity
notificationBuilder: builder for the notification associated with this Ongoing Activity

public Builder(Context context, java.lang.String tag, int notificationId, NotificationCompat.Builder notificationBuilder)

Construct a new empty OngoingActivity.Builder, associated with the given notification.

Parameters:

context: to be used during the life of this OngoingActivity.Builder, will NOT pass a reference into the built OngoingActivity
tag: tag that will be used to post the notification associated with this Ongoing Activity
notificationId: id that will be used to post the notification associated with this Ongoing Activity
notificationBuilder: builder for the notification associated with this Ongoing Activity

Methods

public OngoingActivity.Builder setAnimatedIcon(Icon animatedIcon)

Set the animated icon that can be used on some surfaces to represent this OngoingActivity. For example, in the WatchFace. Should be white with a transparent background, preferably an AnimatedVectorDrawable.

If not provided, or set to null, the static icon will be used.

public OngoingActivity.Builder setStaticIcon(Icon staticIcon)

Set the static icon that can be used on some surfaces to represent this OngoingActivity, for example in the WatchFace in ambient mode. Should be white with a transparent background, preferably a VectorDrawable.

If not set, the smallIcon of the notification will be used. If neither is set, OngoingActivity.Builder.build() will throw an exception.

public OngoingActivity.Builder setStatus(Status status)

Set the initial status of this ongoing activity, the status may be displayed on the UI to show progress of the Ongoing Activity.

If not provided, the contentText of the notification will be used.

public OngoingActivity.Builder setTouchIntent(PendingIntent touchIntent)

Set the intent to be used to go back to the activity when the user interacts with the Ongoing Activity in other surfaces (for example, taps the Icon on the WatchFace).

If not set, the contentIntent of the notification will be used. If neither is set, OngoingActivity.Builder.build() will throw an exception.

public OngoingActivity.Builder setLocusId(LocusIdCompat locusId)

Set the corresponding LocusId of this OngoingActivity, this will be used by the launcher to identify the corresponding launcher item and display it accordingly.

If set to null or not set, the launcher will use heuristics to do the matching.

public OngoingActivity.Builder setOngoingActivityId(int ongoingActivityId)

Give an id to this OngoingActivity, as a way to reference it in OngoingActivity.recoverOngoingActivity(Context, int)

public OngoingActivity.Builder setCategory(java.lang.String category)

Set the category of this OngoingActivity. It may be used by the system to prioritize displaying the OngoingActivity.

If set, it Must be one of the predefined notification categories (see the CATEGORY_* constants in NotificationCompat) that best describes this OngoingActivity.

If this is not set (or null), the notification's category is used if present.

public OngoingActivity.Builder setTitle(java.lang.String title)

Sets the Title of this OngoingActivity. If this is set to a non-null value, it could be used by the launcher to override the app's title.

No defaults from the notification are used for this field.

public OngoingActivity build()

Combine all options provided and the information in the notification if needed, return a new OngoingActivity object. See particular setters for information on what defaults from the notification are used.