Class LiveActivity
A running live activity: an ongoing-state surface (delivery, timer, ride, score) presented on the iOS lock screen and Dynamic Island, as an ongoing Android notification, or as a floating pill window on desktop. Start it with a descriptor and an initial state, then push fresh state maps as the situation evolves -- updates ship only the state, the layout is re-interpolated on the surface:
LiveActivity delivery = LiveActivity.start(descriptor, initialState);
...
delivery.update(stateMap("Arriving now", eta, 1.0f));
delivery.end(null);
On platforms without live activity support start(...) returns an inert handle whose methods
are safe no-ops (isActive() returns false), so app code needs no platform checks.
-
Method Summary
Modifier and TypeMethodDescriptionvoidEnds the activity, optionally showing a final state before the platform dismisses the surface.voidEnds the activity.getId()Returns the platform id of the activity, or null for inert handles.booleanisActive()Returns true while the activity is running (false for inert handles and afterend).static booleanReturns true when this platform can present live activities.static LiveActivitystart(LiveActivityDescriptor descriptor, Map<String, Object> initialState) Starts a live activity.voidPushes a fresh state map to the running activity.
-
Method Details
-
isSupported
public static boolean isSupported()Returns true when this platform can present live activities.
Returns
true when live activities are supported
-
start
public static LiveActivity start(LiveActivityDescriptor descriptor, Map<String, Object> initialState) Starts a live activity. On unsupported platforms (or when the platform refuses, e.g. the user disabled live activities) this returns an inert handle rather than throwing.
Parameters
descriptor: the activity layout and regionsinitialState: the initial state map, may be null
Returns
a handle to the running activity; check
isActive()to know whether it is live -
update
-
end
-
end
-
isActive
public boolean isActive()Returns true while the activity is running (false for inert handles and afterend). -
getId
Returns the platform id of the activity, or null for inert handles. Action events from this activity carry the descriptor's activity type as their source.
-