Stay organized with collections
Save and categorize content based on your preferences.
PrimarySessionStateCallback
@RequiresApi(value = 26) interface PrimarySessionStateCallback extends SessionStateCallback
Clients of Sessions should implement PrimarySessionStateCallback
to receive notifications of Session state changes when acting as the Primary for a Shared Session.
Provide your implementation in Sessions.shareSession
.
Summary
Public methods |
abstract void |
Called when a secondary leaves the specified session.
|
abstract void |
Called when a secondary joins the specified session.
|
abstract void |
Called when a PrimarySession has no active secondaries (and no joins in progress).
|
abstract void |
Called when share cannot complete with a specific participant.
|
abstract void |
Called when a set of participants is provided with a Share request from this Primary.
|
Public methods
onShareInitiated
abstract void onShareInitiated(
@NonNull SessionId sessionId,
int numPotentialParticipants
)
Called when a set of participants is provided with a Share request from this Primary. This method will be called once for each application call to Sessions.shareSession
.
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 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# PrimarySessionStateCallback\n===========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback \"View this page in Kotlin\") \\|Java\n\n\n```\n@RequiresApi(value = 26) interface PrimarySessionStateCallback extends SessionStateCallback\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nClients of Sessions should implement `PrimarySessionStateCallback` to receive notifications of Session state changes when acting as the Primary for a Shared Session.\n\nProvide your implementation in [Sessions.shareSession](/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback)).\n\nSummary\n-------\n\n| ### Public methods ||\n|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `abstract void` | [onParticipantDeparted](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onParticipantDeparted(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionParticipant))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionId](/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionParticipant](/reference/com/google/ambient/crossdevice/sessions/SessionParticipant)` participant` `)` Called when a secondary leaves the specified session. |\n| `abstract void` | [onParticipantJoined](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onParticipantJoined(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionParticipant))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionId](/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionParticipant](/reference/com/google/ambient/crossdevice/sessions/SessionParticipant)` participant` `)` Called when a secondary joins the specified session. |\n| `abstract void` | [onPrimarySessionCleanup](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onPrimarySessionCleanup(com.google.ambient.crossdevice.sessions.SessionId))`(@`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionId](/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId)` Called when a [PrimarySession](/reference/com/google/ambient/crossdevice/sessions/PrimarySession) has no active secondaries (and no joins in progress). |\n| `abstract void` | [onShareFailureWithParticipant](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onShareFailureWithParticipant(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionException,com.google.ambient.crossdevice.sessions.SessionParticipant))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionId](/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionException](/reference/com/google/ambient/crossdevice/sessions/SessionException)` exception,` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionParticipant](/reference/com/google/ambient/crossdevice/sessions/SessionParticipant)` participant` `)` Called when share cannot complete with a specific participant. |\n| `abstract void` | [onShareInitiated](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onShareInitiated(com.google.ambient.crossdevice.sessions.SessionId,kotlin.Int))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[SessionId](/reference/com/google/ambient/crossdevice/sessions/SessionId)` sessionId,` ` int numPotentialParticipants` `)` Called when a set of participants is provided with a Share request from this Primary. |\n\nPublic methods\n--------------\n\n### onParticipantDeparted\n\n```\nabstract void onParticipantDeparted(\n @NonNull SessionId sessionId,\n @NonNull SessionParticipant participant\n)\n```\n\nCalled when a secondary leaves the specified session. \n\n### onParticipantJoined\n\n```\nabstract void onParticipantJoined(\n @NonNull SessionId sessionId,\n @NonNull SessionParticipant participant\n)\n```\n\nCalled when a secondary joins the specified session. \n\n### onPrimarySessionCleanup\n\n```\nabstract void onPrimarySessionCleanup(@NonNull SessionId sessionId)\n```\n\nCalled when a [PrimarySession](/reference/com/google/ambient/crossdevice/sessions/PrimarySession) has no active secondaries (and no joins in progress). After this call, continued use of the [PrimarySession](/reference/com/google/ambient/crossdevice/sessions/PrimarySession) will return [SessionException](/reference/com/google/ambient/crossdevice/sessions/SessionException) on all method calls because it is no longer valid. \n\n### onShareFailureWithParticipant\n\n```\nabstract void onShareFailureWithParticipant(\n @NonNull SessionId sessionId,\n @NonNull SessionException exception,\n @NonNull SessionParticipant participant\n)\n```\n\nCalled when share cannot complete with a specific participant. Failure reason described by `exception`. Called on the originating device. \n\n### onShareInitiated\n\n```\nabstract void onShareInitiated(\n @NonNull SessionId sessionId,\n int numPotentialParticipants\n)\n```\n\nCalled when a set of participants is provided with a Share request from this Primary. This method will be called once for each application call to [Sessions.shareSession](/reference/com/google/ambient/crossdevice/sessions/Sessions#shareSession(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.wakeup.StartComponentRequest,kotlin.collections.List,com.google.ambient.crossdevice.sessions.PrimarySessionStateCallback))."]]