Stay organized with collections
Save and categorize content based on your preferences.
ServiceInfoCallback
interface ServiceInfoCallback
Callback to listen to service info updates. For use with NsdManager.registerServiceInfoCallback
to register, and with NsdManager.unregisterServiceInfoCallback
to stop listening.
Summary
Public methods |
abstract Unit |
Reports that registering the callback failed with an error.
|
abstract Unit |
Reports that service info updates have stopped.
|
abstract Unit |
Reports when the service that this callback listens to becomes unavailable.
|
abstract Unit |
Reports updated service info.
|
Public methods
onServiceInfoCallbackRegistrationFailed
abstract fun onServiceInfoCallbackRegistrationFailed(errorCode: Int): Unit
Reports that registering the callback failed with an error. Called on the executor passed to NsdManager.registerServiceInfoCallback
. onServiceInfoCallbackRegistrationFailed will be called exactly once when the callback could not be registered. No other callback will be sent in that case.
onServiceInfoCallbackUnregistered
abstract fun onServiceInfoCallbackUnregistered(): Unit
Reports that service info updates have stopped. Called on the executor passed to NsdManager.registerServiceInfoCallback
. A callback unregistration operation will call onServiceInfoCallbackUnregistered once. After this, the callback may be reused.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# NsdManager.ServiceInfoCallback\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 7](https://developer.android.com/sdkExtensions)\n\nServiceInfoCallback\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/nsd/NsdManager.ServiceInfoCallback \"View this page in Java\") \n\n```\ninterface ServiceInfoCallback\n```\n\n|-----------------------------------------------------|\n| [android.net.nsd.NsdManager.ServiceInfoCallback](#) |\n\nCallback to listen to service info updates. For use with [NsdManager.registerServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)) to register, and with [NsdManager.unregisterServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#unregisterServiceInfoCallback(android.net.nsd.NsdManager.ServiceInfoCallback)) to stop listening.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onServiceInfoCallbackRegistrationFailed](#onServiceInfoCallbackRegistrationFailed(kotlin.Int))`(`errorCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Reports that registering the callback failed with an error. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onServiceInfoCallbackUnregistered](#onServiceInfoCallbackUnregistered())`()` Reports that service info updates have stopped. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onServiceLost](#onServiceLost())`()` Reports when the service that this callback listens to becomes unavailable. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onServiceUpdated](#onServiceUpdated(android.net.nsd.NsdServiceInfo))`(`serviceInfo:` `[NsdServiceInfo](/reference/kotlin/android/net/nsd/NsdServiceInfo)`)` Reports updated service info. |\n\nPublic methods\n--------------\n\n### onServiceInfoCallbackRegistrationFailed\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 7](https://developer.android.com/sdkExtensions) \n\n```\nabstract fun onServiceInfoCallbackRegistrationFailed(errorCode: Int): Unit\n```\n\nReports that registering the callback failed with an error. Called on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). onServiceInfoCallbackRegistrationFailed will be called exactly once when the callback could not be registered. No other callback will be sent in that case.\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `errorCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is [android.net.nsd.NsdManager#FAILURE_ALREADY_ACTIVE](/reference/kotlin/android/net/nsd/NsdManager#FAILURE_ALREADY_ACTIVE:kotlin.Int), or [android.net.nsd.NsdManager#FAILURE_BAD_PARAMETERS](/reference/kotlin/android/net/nsd/NsdManager#FAILURE_BAD_PARAMETERS:kotlin.Int) |\n\n### onServiceInfoCallbackUnregistered\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 7](https://developer.android.com/sdkExtensions) \n\n```\nabstract fun onServiceInfoCallbackUnregistered(): Unit\n```\n\nReports that service info updates have stopped. Called on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). A callback unregistration operation will call onServiceInfoCallbackUnregistered once. After this, the callback may be reused. \n\n### onServiceLost\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 7](https://developer.android.com/sdkExtensions) \n\n```\nabstract fun onServiceLost(): Unit\n```\n\nReports when the service that this callback listens to becomes unavailable. Called on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). The service may become available again, in which case [onServiceUpdated](#onServiceUpdated(android.net.nsd.NsdServiceInfo)) will be called. \n\n### onServiceUpdated\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 7](https://developer.android.com/sdkExtensions) \n\n```\nabstract fun onServiceUpdated(serviceInfo: NsdServiceInfo): Unit\n```\n\nReports updated service info. Called on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). Any service updates will be notified via this callback until [NsdManager.unregisterServiceInfoCallback](/reference/kotlin/android/net/nsd/NsdManager#unregisterServiceInfoCallback(android.net.nsd.NsdManager.ServiceInfoCallback)) is called. This will only be called once the service is found, so may never be called if the service is never present.\n\n| Parameters ||\n|---------------|--------------------------------------------------------------------------------------------------|\n| `serviceInfo` | [NsdServiceInfo](/reference/kotlin/android/net/nsd/NsdServiceInfo): This value cannot be `null`. |"]]