Stay organized with collections
Save and categorize content based on your preferences.
Callback
open class Callback
The callback which app can use to learn the status changes of SocketKeepalive
. See SocketKeepalive
.
Summary
Public methods |
open Unit |
The keepalive on a TCP socket was stopped because the socket received data.
|
open Unit |
An error occurred.
|
open Unit |
The requested keepalive was successfully started.
|
open Unit |
The keepalive was successfully stopped.
|
Public constructors
Public methods
onDataReceived
open fun onDataReceived(): Unit
The keepalive on a TCP socket was stopped because the socket received data. This is never called for UDP sockets.
onError
open fun onError(error: Int): Unit
An error occurred.
onStarted
open fun onStarted(): Unit
The requested keepalive was successfully started.
onStopped
open fun onStopped(): Unit
The keepalive was successfully stopped.
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,["# SocketKeepalive.Callback\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCallback\n========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/SocketKeepalive.Callback \"View this page in Java\") \n\n```\nopen class Callback\n```\n\n|---|-------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.SocketKeepalive.Callback](#) |\n\nThe callback which app can use to learn the status changes of [SocketKeepalive](/reference/kotlin/android/net/SocketKeepalive). See [SocketKeepalive](/reference/kotlin/android/net/SocketKeepalive).\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------|---|\n| [Callback](#Callback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onDataReceived](#onDataReceived())`()` The keepalive on a TCP socket was stopped because the socket received data. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onError](#onError(kotlin.Int))`(`error:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` An error occurred. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStarted](#onStarted())`()` The requested keepalive was successfully started. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStopped](#onStopped())`()` The keepalive was successfully stopped. |\n\nPublic constructors\n-------------------\n\n### Callback\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nCallback()\n```\n\nPublic methods\n--------------\n\n### onDataReceived\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onDataReceived(): Unit\n```\n\nThe keepalive on a TCP socket was stopped because the socket received data. This is never called for UDP sockets. \n\n### onError\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onError(error: Int): Unit\n```\n\nAn error occurred.\n\n| Parameters ||\n|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `error` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is [android.net.SocketKeepalive#ERROR_INVALID_NETWORK](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_NETWORK:kotlin.Int), [android.net.SocketKeepalive#ERROR_INVALID_IP_ADDRESS](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_IP_ADDRESS:kotlin.Int), [android.net.SocketKeepalive#ERROR_INVALID_PORT](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_PORT:kotlin.Int), [android.net.SocketKeepalive#ERROR_INVALID_LENGTH](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_LENGTH:kotlin.Int), [android.net.SocketKeepalive#ERROR_INVALID_INTERVAL](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_INTERVAL:kotlin.Int), [android.net.SocketKeepalive#ERROR_INVALID_SOCKET](/reference/kotlin/android/net/SocketKeepalive#ERROR_INVALID_SOCKET:kotlin.Int), [android.net.SocketKeepalive#ERROR_SOCKET_NOT_IDLE](/reference/kotlin/android/net/SocketKeepalive#ERROR_SOCKET_NOT_IDLE:kotlin.Int), or android.net.SocketKeepalive.ERROR_NO_SUCH_SLOT |\n\n### onStarted\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onStarted(): Unit\n```\n\nThe requested keepalive was successfully started. \n\n### onStopped\n\nAdded in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onStopped(): Unit\n```\n\nThe keepalive was successfully stopped."]]