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

OngoingActivityData

public class OngoingActivityData
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.wear.ongoing.OngoingActivityData


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

Summary

Public methods

static void copy(Bundle sourceBundle, Bundle destinationBundle)

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)

static OngoingActivityData create(Bundle bundle)

Deserializes the OngoingActivityData from a Bundle.

static OngoingActivityData create(Notification notification)

Deserializes the OngoingActivityData from a notification.

Icon getAnimatedIcon()

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

String getCategory()

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

LocusIdCompat getLocusId()

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

int getOngoingActivityId()

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

Icon getStaticIcon()

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

OngoingActivityStatus getStatus()

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

long getTimestamp()

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

PendingIntent getTouchIntent()

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

static boolean hasOngoingActivity(Notification notification)

Checks if the given notification represents an ongoing activity.

Inherited methods

Public methods

copy

public static void copy (Bundle sourceBundle, 
                Bundle destinationBundle)

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

public static OngoingActivityData create (Bundle bundle)

Deserializes the OngoingActivityData from a Bundle.

Parameters
bundle Bundle: the bundle that may contain information about a Ongoing Activity.

Returns
OngoingActivityData the data, or null of the Bundle doesn't contain Ongoing Activity data.

create

public static OngoingActivityData create (Notification notification)

Deserializes the OngoingActivityData from a notification.

Parameters
notification Notification: the notification that may contain information about a Ongoing Activity.

Returns
OngoingActivityData the data, or null of the notification doesn't contain Ongoing Activity data.

getAnimatedIcon

public Icon getAnimatedIcon ()

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

Returns
Icon

getCategory

public String getCategory ()

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

Returns
String

getLocusId

public LocusIdCompat getLocusId ()

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.

Returns
LocusIdCompat

getOngoingActivityId

public int getOngoingActivityId ()

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

Returns
int

getStaticIcon

public Icon getStaticIcon ()

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.

Returns
Icon

getStatus

public OngoingActivityStatus getStatus ()

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.

Returns
OngoingActivityStatus

getTimestamp

public long getTimestamp ()

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

Returns
long

getTouchIntent

public PendingIntent getTouchIntent ()

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). If not set, returns the touch intent of the corresponding Notification.

Returns
PendingIntent

hasOngoingActivity

public static boolean hasOngoingActivity (Notification notification)

Checks if the given notification represents an ongoing activity.

Parameters
notification Notification

Returns
boolean