Stay organized with collections
Save and categorize content based on your preferences.
ConnectionReceiver
@RequiresApi(value = 26) interface ConnectionReceiver
Receiver callback for a RemoteConnection
.
Summary
Public functions
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,["# ConnectionReceiver\n==================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver \"View this page in Java\")\n\n\n```\n@RequiresApi(value = 26) interface ConnectionReceiver\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nReceiver callback for a [RemoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/RemoteConnection).\n\nSummary\n-------\n\n| ### Public functions ||\n|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](/reference/kotlin/kotlin/Unit) | [onConnectionClosed](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String))`(` ` remoteConnection: `[RemoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/RemoteConnection)`,` ` error: `[Throwable](/reference/kotlin/kotlin/Throwable)`?,` ` reason: `[String](/reference/kotlin/kotlin/String)`?` `)` Called when the [remoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String)) is closed. |\n| [Unit](/reference/kotlin/kotlin/Unit) | [onMessageReceived](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray))`(remoteConnection: `[RemoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/RemoteConnection)`, payload: `[ByteArray](/reference/kotlin/kotlin/ByteArray)`)` Called when a message is received on the [remoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray)). |\n\nPublic functions\n----------------\n\n### onConnectionClosed\n\n```\nfun onConnectionClosed(\n remoteConnection: RemoteConnection,\n error: Throwable? = null,\n reason: String? = null\n): Unit\n```\n\nCalled when the [remoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String)) is closed. \n\n| Parameters ||\n|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `remoteConnection: `[RemoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/RemoteConnection) | The remote connection that is closed. |\n| `error: `[Throwable](/reference/kotlin/kotlin/Throwable)`? = null` | The error causing the connection to be closed, or `null` if the connection was closed normally. |\n| `reason: `[String](/reference/kotlin/kotlin/String)`? = null` | The reason indicated by the remote end of the connection in their call to [RemoteConnection.close](/reference/kotlin/com/google/ambient/crossdevice/connections/RemoteConnection#close(kotlin.String)). |\n\n### onMessageReceived\n\n```\nfun onMessageReceived(remoteConnection: RemoteConnection, payload: ByteArray): Unit\n```\n\nCalled when a message is received on the [remoteConnection](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray))."]]