OngoingActivity.Builder

public final class OngoingActivity.Builder


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 Builder will be used.

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

Summary

Public constructors

Builder(
    @NonNull Context context,
    int notificationId,
    @NonNull NotificationCompat.Builder notificationBuilder
)

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

Builder(
    @NonNull Context context,
    @NonNull String tag,
    int notificationId,
    @NonNull NotificationCompat.Builder notificationBuilder
)

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

Public methods

@NonNull OngoingActivity

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

@NonNull OngoingActivity.Builder
setAnimatedIcon(@Nullable Icon animatedIcon)

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

@NonNull OngoingActivity.Builder
setAnimatedIcon(@DrawableRes int animatedIcon)

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

@NonNull OngoingActivity.Builder

Set the category of this OngoingActivity.

@NonNull OngoingActivity.Builder

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

@NonNull OngoingActivity.Builder
setOngoingActivityId(int ongoingActivityId)

Give an id to this OngoingActivity, as a way to reference it in recoverOngoingActivity

@NonNull OngoingActivity.Builder
setStaticIcon(@NonNull 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.

@NonNull OngoingActivity.Builder
setStaticIcon(@DrawableRes int staticIcon)

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

@NonNull OngoingActivity.Builder

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

@NonNull OngoingActivity.Builder

Sets the Title of this OngoingActivity.

@NonNull OngoingActivity.Builder

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).

Public constructors

Builder

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

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

Parameters
@NonNull Context context

to be used during the life of this Builder, will NOT pass a reference into the built OngoingActivity

int notificationId

id that will be used to post the notification associated with this Ongoing Activity

@NonNull NotificationCompat.Builder notificationBuilder

builder for the notification associated with this Ongoing Activity

Builder

public Builder(
    @NonNull Context context,
    @NonNull String tag,
    int notificationId,
    @NonNull NotificationCompat.Builder notificationBuilder
)

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

Parameters
@NonNull Context context

to be used during the life of this Builder, will NOT pass a reference into the built OngoingActivity

@NonNull String tag

tag that will be used to post the notification associated with this Ongoing Activity

int notificationId

id that will