Stay organized with collections
Save and categorize content based on your preferences.
PrimarySessionStateCallback
@RequiresApi(value = 26) interface PrimarySessionStateCallback : 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 functions |
Unit |
Called when a secondary leaves the specified session.
|
Unit |
Called when a secondary joins the specified session.
|
Unit |
Called when a PrimarySession has no active secondaries (and no joins in progress).
|
Unit |
Called when share cannot complete with a specific participant.
|
Unit |
Called when a set of participants is provided with a Share request from this Primary.
|
Public functions
onShareInitiated
fun onShareInitiated(sessionId: SessionId, numPotentialParticipants: Int): Unit
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\nKotlin \\|[Java](/reference/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback \"View this page in Java\")\n\n\n```\n@RequiresApi(value = 26) interface PrimarySessionStateCallback : 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/kotlin/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 functions ||\n|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](/reference/kotlin/kotlin/Unit) | [onParticipantDeparted](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onParticipantDeparted(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionParticipant))`(` ` sessionId: `[SessionId](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionId)`,` ` participant: `[SessionParticipant](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionParticipant) `)` Called when a secondary leaves the specified session. |\n| [Unit](/reference/kotlin/kotlin/Unit) | [onParticipantJoined](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onParticipantJoined(com.google.ambient.crossdevice.sessions.SessionId,com.google.ambient.crossdevice.sessions.SessionParticipant))`(` ` sessionId: `[SessionId](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionId)`,` ` participant: `[SessionParticipant](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionParticipant) `)` Called when a secondary joins the specified session. |\n| [Unit](/reference/kotlin/kotlin/Unit) | [onPrimarySessionCleanup](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onPrimarySessionCleanup(com.google.ambient.crossdevice.sessions.SessionId))`(sessionId: `[SessionId](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionId)`)` Called when a [PrimarySession](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySession) has no active secondaries (and no joins in progress). |\n| [Unit](/reference/kotlin/kotlin/Unit) | [onShareFailureWithParticipant](/reference/kotlin/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))`(` ` sessionId: `[SessionId](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionId)`,` ` exception: `[SessionException](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionException)`,` ` participant: `[SessionParticipant](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionParticipant) `)` Called when share cannot complete with a specific participant. |\n| [Unit](/reference/kotlin/kotlin/Unit) | [onShareInitiated](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySessionStateCallback#onShareInitiated(com.google.ambient.crossdevice.sessions.SessionId,kotlin.Int))`(sessionId: `[SessionId](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionId)`, numPotentialParticipants: `[Int](/reference/kotlin/kotlin/Int)`)` Called when a set of participants is provided with a Share request from this Primary. |\n\nPublic functions\n----------------\n\n### onParticipantDeparted\n\n```\nfun onParticipantDeparted(\n sessionId: SessionId,\n participant: SessionParticipant\n): Unit\n```\n\nCalled when a secondary leaves the specified session. \n\n### onParticipantJoined\n\n```\nfun onParticipantJoined(\n sessionId: SessionId,\n participant: SessionParticipant\n): Unit\n```\n\nCalled when a secondary joins the specified session. \n\n### onPrimarySessionCleanup\n\n```\nfun onPrimarySessionCleanup(sessionId: SessionId): Unit\n```\n\nCalled when a [PrimarySession](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySession) has no active secondaries (and no joins in progress). After this call, continued use of the [PrimarySession](/reference/kotlin/com/google/ambient/crossdevice/sessions/PrimarySession) will return [SessionException](/reference/kotlin/com/google/ambient/crossdevice/sessions/SessionException) on all method calls because it is no longer valid. \n\n### onShareFailureWithParticipant\n\n```\nfun onShareFailureWithParticipant(\n sessionId: SessionId,\n exception: SessionException,\n participant: SessionParticipant\n): Unit\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```\nfun onShareInitiated(sessionId: SessionId, numPotentialParticipants: Int): Unit\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/kotlin/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))."]]