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 methods
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\n[Kotlin](/reference/kotlin/com/google/ambient/crossdevice/connections/ConnectionReceiver \"View this page in Kotlin\") \\|Java\n\n\n```\n@RequiresApi(value = 26) interface ConnectionReceiver\n```\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nReceiver callback for a [RemoteConnection](/reference/com/google/ambient/crossdevice/connections/RemoteConnection).\n\nSummary\n-------\n\n| ### Public methods ||\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `abstract void` | [onConnectionClosed](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[RemoteConnection](/reference/com/google/ambient/crossdevice/connections/RemoteConnection)` remoteConnection,` ` `[Throwable](/reference/java/lang/Throwable)` error,` ` `[String](/reference/java/lang/String)` reason` `)` Called when the [remoteConnection](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String)) is closed. |\n| `abstract void` | [onMessageReceived](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray))`(` ` @`[NonNull](/reference/androidx/annotation/NonNull)` `[RemoteConnection](/reference/com/google/ambient/crossdevice/connections/RemoteConnection)` remoteConnection,` ` @`[NonNull](/reference/androidx/annotation/NonNull)` byte[] payload` `)` Called when a message is received on the [remoteConnection](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray)). |\n\nPublic methods\n--------------\n\n### onConnectionClosed\n\n```\nabstract void onConnectionClosed(\n @NonNull RemoteConnection remoteConnection,\n Throwable error,\n String reason\n)\n```\n\nCalled when the [remoteConnection](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onConnectionClosed(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.Throwable,kotlin.String)) is closed. \n\n| Parameters ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `@`[NonNull](/reference/androidx/annotation/NonNull)` `[RemoteConnection](/reference/com/google/ambient/crossdevice/connections/RemoteConnection)` remoteConnection` | The remote connection that is closed. |\n| [Throwable](/reference/java/lang/Throwable)` error` | The error causing the connection to be closed, or `null` if the connection was closed normally. |\n| [String](/reference/java/lang/String)` reason` | The reason indicated by the remote end of the connection in their call to [RemoteConnection.close](/reference/com/google/ambient/crossdevice/connections/RemoteConnection#close(kotlin.String)). |\n\n### onMessageReceived\n\n```\nabstract void onMessageReceived(\n @NonNull RemoteConnection remoteConnection,\n @NonNull byte[] payload\n)\n```\n\nCalled when a message is received on the [remoteConnection](/reference/com/google/ambient/crossdevice/connections/ConnectionReceiver#onMessageReceived(com.google.ambient.crossdevice.connections.RemoteConnection,kotlin.ByteArray))."]]