Added in API level 34
Also in T Extensions 7

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

abstract void onServiceInfoCallbackRegistrationFailed(int errorCode)

Reports that registering the callback failed with an error.

abstract void onServiceInfoCallbackUnregistered()

Reports that service info updates have stopped.

abstract void onServiceLost()

Reports when the service that this callback listens to becomes unavailable.

abstract void onServiceUpdated(NsdServiceInfo serviceInfo)

Reports updated service info.

Public methods

onServiceInfoCallbackRegistrationFailed

Added in API level 34
Also in T Extensions 7
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.

Parameters
errorCode int: Value is NsdManager.FAILURE_ALREADY_ACTIVE, or NsdManager.FAILURE_BAD_PARAMETERS

onServiceInfoCallbackUnregistered

Added in API level 34
Also in T Extensions 7
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.

onServiceLost

Added in API level 34
Also in T Extensions 7
public abstract void onServiceLost ()

Reports when the service that this callback listens to becomes unavailable. Called on the executor passed to NsdManager.registerServiceInfoCallback. The service may become available again, in which case onServiceUpdated(NsdServiceInfo) will be called.

onServiceUpdated

Added in API level 34
Also in T Extensions 7
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.