AppInteractionSession
public
final
class
AppInteractionSession
extends Object
implements
AutoCloseable
| java.lang.Object | |
| ↳ | android.app.AppInteractionSession |
Represents an app interaction session.
The session is used to associate app interactions with a continuous context. For example, a session can be used to keep track of the user consent for the lifetime of the session. Developers could use it to associate with relevant queries from users. For example, in a thread where a user starts asking an agent to perform a task, developers could start a session and keep track of all relevant actions within that session. So that if they need to access the same apps twice during that thread, they don't need to ask permission twice.
The session will be automatically closed when reaching the maximum allowed lifetime. The
session owner will be notified of the close event via the AppInteractionSession.LifecycleListener.onAppInteractionSessionClosed with AppInteractionSession.CLOSE_REASON_TIMEOUT.
See also:
Summary
Nested classes | |
|---|---|
class |
AppInteractionSession.CreateParams
Parameters to create an |
interface |
AppInteractionSession.LifecycleListener
Listener for session lifecycle events. |
class |
AppInteractionSession.UpdateParams
Parameters to update an |
Constants | |
|---|---|
int |
CLOSE_REASON_CALLER_INITIATED
The session is closed due to the caller calling |
int |
CLOSE_REASON_TIMEOUT
The session is closed due to timeout. |
int |
CLOSE_REASON_UNKNOWN
Unknown reason for the session to be closed. |
Public methods | |
|---|---|
void
|
addLifecycleListener(Executor executor, AppInteractionSession.LifecycleListener listener)
Adds a listener to receive session lifecycle events. |
void
|
close()
Closes the session. |
void
|
removeLifecycleListener(AppInteractionSession.LifecycleListener listener)
Removes a previously registered session lifecycle listener. |
void
|
)">update(AppInteractionSession.UpdateParams params, Executor executor, OutcomeReceiver<Void, AppInteractionException> callback)
Updates the session with the given |
Inherited methods | |
|---|---|
Constants
CLOSE_REASON_CALLER_INITIATED
public static final int CLOSE_REASON_CALLER_INITIATED
The session is closed due to the caller calling close().
Constant Value: 2 (0x00000002)
CLOSE_REASON_TIMEOUT
public static final int CLOSE_REASON_TIMEOUT
The session is closed due to timeout.
Constant Value: 1 (0x00000001)
CLOSE_REASON_UNKNOWN
public static final int CLOSE_REASON_UNKNOWN
Unknown reason for the session to be closed.
Constant Value: 0 (0x00000000)
Public methods
addLifecycleListener
public void addLifecycleListener (Executor executor, AppInteractionSession.LifecycleListener listener)
Adds a listener to receive session lifecycle events.
| Parameters | |
|---|---|
executor |
Executor: The Executor on which to invoke the callback.
This value cannot be null.
Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
listener |
AppInteractionSession.LifecycleListener: The LifecycleListener to receive lifecycle events.
This value cannot be null. |
removeLifecycleListener
public void removeLifecycleListener (AppInteractionSession.LifecycleListener listener)
Removes a previously registered session lifecycle listener.
| Parameters | |
|---|---|
listener |
AppInteractionSession.LifecycleListener: The LifecycleListener that should no longer receive lifecycle events.
This value cannot be null. |
update
public void update (AppInteractionSession.UpdateParams params, Executor executor, OutcomeReceiver<Void, AppInteractionException> callback)
Updates the session with the given params.
| Parameters | |
|---|---|
params |
AppInteractionSession.UpdateParams: The parameters to update the session with.
This value cannot be null. |
executor |
Executor: The Executor on which to invoke the callback.
This value cannot be null.
Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is
used. To dispatch events through the main thread of your
application, you can use
Context.getMainExecutor().
Otherwise, provide an Executor that dispatches to an appropriate thread. |
callback |
OutcomeReceiver: The OutcomeReceiver to receive the result of the update.
This value cannot be null. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-08-28 UTC.
| Web Proxy Viewer | New URL | Original Page |