Stay organized with collections
Save and categorize content based on your preferences.
NsdManager.ServiceInfoCallback
public
static
interface
NsdManager.ServiceInfoCallback
android.net.nsd.NsdManager.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
onServiceInfoCallbackRegistrationFailed
public abstract void onServiceInfoCallbackRegistrationFailed (int errorCode)
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
public abstract void onServiceInfoCallbackUnregistered ()
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.
onServiceUpdated
public abstract void onServiceUpdated (NsdServiceInfo serviceInfo)
Reports updated service info.
Called on the executor passed to NsdManager.registerServiceInfoCallback
. Any
service updates will be notified via this callback until
NsdManager.unregisterServiceInfoCallback
is called. This will only be called once
the service is found, so may never be called if the service is never present.
Parameters |
serviceInfo |
NsdServiceInfo : This value cannot be null . |
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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [T Extensions 7](/sdkExtensions) \n\nNsdManager.ServiceInfoCallback\n==============================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/net/nsd/NsdManager.ServiceInfoCallback \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nNsdManager.ServiceInfoCallback\n`\n\n\n`\n\n\n`\n\n|------------------------------------------------|\n| android.net.nsd.NsdManager.ServiceInfoCallback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCallback to listen to service info updates.\n\nFor use with [NsdManager.registerServiceInfoCallback](/reference/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)) to register, and with\n[NsdManager.unregisterServiceInfoCallback](/reference/android/net/nsd/NsdManager#unregisterServiceInfoCallback(android.net.nsd.NsdManager.ServiceInfoCallback)) to stop listening.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onServiceInfoCallbackRegistrationFailed](/reference/android/net/nsd/NsdManager.ServiceInfoCallback#onServiceInfoCallbackRegistrationFailed(int))`(int errorCode) ` Reports that registering the callback failed with an error. |\n| ` abstract void` | ` `[onServiceInfoCallbackUnregistered](/reference/android/net/nsd/NsdManager.ServiceInfoCallback#onServiceInfoCallbackUnregistered())`() ` Reports that service info updates have stopped. |\n| ` abstract void` | ` `[onServiceLost](/reference/android/net/nsd/NsdManager.ServiceInfoCallback#onServiceLost())`() ` Reports when the service that this callback listens to becomes unavailable. |\n| ` abstract void` | ` `[onServiceUpdated](/reference/android/net/nsd/NsdManager.ServiceInfoCallback#onServiceUpdated(android.net.nsd.NsdServiceInfo))`(`[NsdServiceInfo](/reference/android/net/nsd/NsdServiceInfo)` serviceInfo) ` Reports updated service info. |\n\nPublic methods\n--------------\n\n### onServiceInfoCallbackRegistrationFailed\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [T Extensions 7](/sdkExtensions) \n\n```\npublic abstract void onServiceInfoCallbackRegistrationFailed (int errorCode)\n```\n\nReports that registering the callback failed with an error.\n\nCalled on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)).\n\nonServiceInfoCallbackRegistrationFailed will be called exactly once when the callback\ncould not be registered. No other callback will be sent in that case.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `errorCode` | `int`: Value is [NsdManager.FAILURE_ALREADY_ACTIVE](/reference/android/net/nsd/NsdManager#FAILURE_ALREADY_ACTIVE), or [NsdManager.FAILURE_BAD_PARAMETERS](/reference/android/net/nsd/NsdManager#FAILURE_BAD_PARAMETERS) \u003cbr /\u003e |\n\n### onServiceInfoCallbackUnregistered\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [T Extensions 7](/sdkExtensions) \n\n```\npublic abstract void onServiceInfoCallbackUnregistered ()\n```\n\nReports that service info updates have stopped.\n\nCalled on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)).\n\nA callback unregistration operation will call onServiceInfoCallbackUnregistered\nonce. After this, the callback may be reused.\n\n\u003cbr /\u003e\n\n### onServiceLost\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [T Extensions 7](/sdkExtensions) \n\n```\npublic abstract void onServiceLost ()\n```\n\nReports when the service that this callback listens to becomes unavailable.\n\nCalled on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). The\nservice may become available again, in which case [onServiceUpdated(NsdServiceInfo)](/reference/android/net/nsd/NsdManager.ServiceInfoCallback#onServiceUpdated(android.net.nsd.NsdServiceInfo)) will be\ncalled.\n\n\u003cbr /\u003e\n\n### onServiceUpdated\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [T Extensions 7](/sdkExtensions) \n\n```\npublic abstract void onServiceUpdated (NsdServiceInfo serviceInfo)\n```\n\nReports updated service info.\n\nCalled on the executor passed to [NsdManager.registerServiceInfoCallback](/reference/android/net/nsd/NsdManager#registerServiceInfoCallback(android.net.nsd.NsdServiceInfo,%20java.util.concurrent.Executor,%20android.net.nsd.NsdManager.ServiceInfoCallback)). Any\nservice updates will be notified via this callback until\n[NsdManager.unregisterServiceInfoCallback](/reference/android/net/nsd/NsdManager#unregisterServiceInfoCallback(android.net.nsd.NsdManager.ServiceInfoCallback)) is called. This will only be called once\nthe service is found, so may never be called if the service is never present.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|-------------------------------------------------------|\n| `serviceInfo` | `NsdServiceInfo`: This value cannot be `null`. \u003cbr /\u003e |"]]