Builder
class Builder
kotlin.Any | |
↳ | androidx.wear.ongoing.OngoingActivity.Builder |
Builder used to build an OngoingActivity
Summary
Public constructors | |
---|---|
<init>(@NonNull context: Context, notificationId: Int, @NonNull notificationBuilder: NotificationCompat.Builder) Construct a new empty |
Public methods | |
---|---|
OngoingActivity |
build() Combine all options provided and the information in the notification if needed, return a new |
OngoingActivity.Builder |
setAnimatedIcon(@NonNull animatedIcon: Icon) Set the animated icon that can be used on some surfaces to represent this |
OngoingActivity.Builder |
setAnimatedIcon(@DrawableRes animatedIcon: Int) Set the animated icon that can be used on some surfaces to represent this |
OngoingActivity.Builder |
setCategory(@NonNull category: String) Set the category of this |
OngoingActivity.Builder |
setLocusId(@NonNull locusId: LocusIdCompat) Set the corresponding LocusId of this |
OngoingActivity.Builder |
setOngoingActivityId(ongoingActivityId: Int) Give an id to this |
OngoingActivity.Builder |
setStaticIcon(@NonNull staticIcon: Icon) Set the animated icon that can be used on some surfaces to represent this |
OngoingActivity.Builder |
setStaticIcon(@DrawableRes staticIcon: Int) Set the animated icon that can be used on some surfaces to represent this |
OngoingActivity.Builder |
setStatus(@NonNull status: OngoingActivityStatus) Set the initial status of this ongoing activity, the status may be displayed on the UI to show progress of the Ongoing Activity. |
OngoingActivity.Builder |
setTouchIntent(@NonNull touchIntent: PendingIntent) 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
<init>
Builder(
@NonNull context: Context,
notificationId: Int,
@NonNull notificationBuilder: NotificationCompat.Builder)
Construct a new empty Builder
, associated with the given notification.
Parameters | |
---|---|
context |
Context: to be used during the life of this Builder , will NOT pass a reference into the built OngoingActivity |
notificationId |
Int: id that will be used to post the notification associated with this Ongoing Activity |
notificationBuilder |
NotificationCompat.Builder: builder for the notification associated with this Ongoing Activity |
Public methods
build
@NonNull fun build(): OngoingActivity
Combine all options provided and the information in the notification if needed, return a new OngoingActivity
object.
Exceptions | |
---|---|
IllegalArgumentException |
if the static icon or the touch intent are not provided. |
setAnimatedIcon
@NonNull fun setAnimatedIcon(@NonNull animatedIcon: Icon): OngoingActivity.Builder
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.
setAnimatedIcon
@NonNull fun setAnimatedIcon(@DrawableRes animatedIcon: Int): OngoingActivity.Builder
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.
setCategory
@NonNull fun setCategory(@NonNull category: String): OngoingActivity.Builder
Set the category of this OngoingActivity
, this may be used by the system to prioritize it.
setLocusId
@NonNull fun setLocusId(@NonNull locusId: LocusIdCompat): 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.
setOngoingActivityId
@NonNull fun setOngoingActivityId(ongoingActivityId: Int): OngoingActivity.Builder
Give an id to this OngoingActivity
, as a way to reference it in OngoingActivity#fromExistingOngoingActivity(Context, int)
setStaticIcon
@NonNull fun setStaticIcon(@NonNull staticIcon: Icon): OngoingActivity.Builder
Set the animated 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 an VectorDrawable.