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

OngoingActivityData

open class OngoingActivityData : VersionedParcelable
kotlin.Any
   ↳ androidx.wear.ongoing.OngoingActivityData

This class is used internally by the library to represent the data of an OngoingActivity.

Summary

Public methods
open static Unit
copy(@NonNull sourceBundle: Bundle, @NonNull destinationBundle: Bundle)

Copies an Ongoing Activity information from a bundle to another, without deserializing and serializing (Note that Bundle instance is shared, not copied and deserializing the Ongoing activity information somewhere else negates the advantages of using this)

open static OngoingActivityData?
create(@NonNull notification: Notification)

Deserializes the OngoingActivityData from a notification.

open static OngoingActivityData?
create(@NonNull bundle: Bundle)

Deserializes the OngoingActivityData from a Bundle.

open Icon?

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

open String?

Get the Category of this OngoingActivity if set, otherwise the category of the corresponding notification.

open LocusIdCompat?

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

open Int

Give the id to this OngoingActivity, as a way to reference it in [fromExistingOngoingActivity]

open Icon

Get the static icon that can be used on some surfaces to represent this OngoingActivity.

open OngoingActivityStatus?

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

open Long

Get the time (in SystemClock#elapsedRealtime() time) the OngoingActivity was built.

open PendingIntent

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

open static Boolean
hasOngoingActivity(@NonNull notification: Notification)

Checks if the given notification represents an ongoing activity.

Public methods

copy

open static fun copy(
    @NonNull sourceBundle: Bundle,
    @NonNull destinationBundle: Bundle
): Unit

Copies an Ongoing Activity information from a bundle to another, without deserializing and serializing (Note that Bundle instance is shared, not copied and deserializing the Ongoing activity information somewhere else negates the advantages of using this)

Parameters
sourceBundle Bundle: The bundle to get the Ongoing Activity data from
destinationBundle Bundle: The bundle to put the Ongoing Activity data into.

create

@Nullable open static fun create(@NonNull notification: Notification): OngoingActivityData?

Deserializes the OngoingActivityData from a notification.

Parameters
notification Notification: the notification that may contain information about a Ongoing Activity.
Return
OngoingActivityData? the data, or null of the notification doesn't contain Ongoing Activity data.

create

@Nullable open static fun create(@NonNull bundle: Bundle): OngoingActivityData?

Deserializes the OngoingActivityData from a Bundle.

Parameters
bundle Bundle: the bundle that may contain information about a Ongoing Activity.
Return
OngoingActivityData? the data, or null of the Bundle doesn't contain Ongoing Activity data.

getAnimatedIcon

@Nullable open fun getAnimatedIcon(): Icon?

Get the animated icon that can be used on some surfaces to represent this OngoingActivity. For example, in the WatchFace.

getCategory

@Nullable open fun getCategory(): String?

Get the Category of this OngoingActivity if set, otherwise the category of the corresponding notification.

getLocusId

@Nullable open fun getLocusId(): LocusIdCompat?

Get the LocusId of this OngoingActivity, this can be used by the launcher to identify the corresponding launcher item and display it accordingly. If not set, returns the one in the corresponding Notification.

getOngoingActivityId

open fun getOngoingActivityId(): Int

Give the id to this OngoingActivity, as a way to reference it in [fromExistingOngoingActivity]

getStaticIcon

@NonNull open fun getStaticIcon(): Icon

Get the static icon that can be used on some surfaces to represent this OngoingActivity. For example in the WatchFace in ambient mode. If not set, returns the small icon of the corresponding Notification.

getStatus

@Nullable open fun getStatus(): OngoingActivityStatus?

Get the status of this ongoing activity, the status may be displayed on the UI to show progress of the Ongoing Activity. If not set, returns the content text of the corresponding Notification.

getTimestamp

open fun getTimestamp(): Long

Get the time (in SystemClock#elapsedRealtime() time) the OngoingActivity was built.

getTouchIntent

@NonNull open