[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/android/app/AppInteractionSession [Back]  [Original]

AppInteractionSession  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.

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 AppInteractionSession, provided to )">AppInteractionManager.createSession

interface AppInteractionSession.LifecycleListener

Listener for session lifecycle events. 

class AppInteractionSession.UpdateParams

Parameters to update an AppInteractionSession, provided to )">AppInteractionSession.update

Constants

int CLOSE_REASON_CALLER_INITIATED

The session is closed due to the caller calling close().

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<VoidAppInteractionException> callback)

Updates the session with the given params.

Inherited methods

Constants

CLOSE_REASON_CALLER_INITIATED

Added in version 37.2
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

Added in version 37.2
public static final int CLOSE_REASON_TIMEOUT

The session is closed due to timeout.

Constant Value: 1 (0x00000001)

CLOSE_REASON_UNKNOWN

Added in version 37.2
public static final int CLOSE_REASON_UNKNOWN

Unknown reason for the session to be closed.

Constant Value: 0 (0x00000000)

Public methods

addLifecycleListener

Added in version 37.2
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.

close

Added in version 37.2
public void close ()

Closes the session.

removeLifecycleListener

Added in version 37.2
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

Added in version 37.2
public void update (AppInteractionSession.UpdateParams params, 
                Executor executor, 
                OutcomeReceiver<VoidAppInteractionException> 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.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-28 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page