Language

NsdManager.DiscoverServices Method

Definition

Overloads

Name Description
DiscoverServices(DiscoveryRequest, IExecutor, NsdManager+IDiscoveryListener)

Initiates service discovery to browse for instances of a service type.

DiscoverServices(String, NsdProtocol, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

DiscoverServices(String, NsdProtocol, Network, IExecutor, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

DiscoverServices(String, NsdProtocol, NetworkRequest, IExecutor, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

DiscoverServices(DiscoveryRequest, IExecutor, NsdManager+IDiscoveryListener)

Initiates service discovery to browse for instances of a service type.

[Android.Runtime.Register("discoverServices", "(Landroid/net/nsd/DiscoveryRequest;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=35)]
public void DiscoverServices(Android.Net.Nsd.DiscoveryRequest discoveryRequest, Java.Util.Concurrent.IExecutor executor, Android.Net.Nsd.NsdManager.IDiscoveryListener listener);
[<Android.Runtime.Register("discoverServices", "(Landroid/net/nsd/DiscoveryRequest;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=35)>]
member this.DiscoverServices : Android.Net.Nsd.DiscoveryRequest * Java.Util.Concurrent.IExecutor * Android.Net.Nsd.NsdManager.IDiscoveryListener -> unit

Parameters

discoveryRequest
DiscoveryRequest

the DiscoveryRequest object which specifies the discovery parameters such as service type, subtype and network. This value cannot be null.

executor
IExecutor

Executor to run listener callbacks with. This value cannot be null.

listener
NsdManager.IDiscoveryListener

The listener notifies of a successful discovery and is used to stop discovery on this serviceType through a call on stopServiceDiscovery(DiscoveryListener). This value cannot be null.

Attributes

Remarks

Initiates service discovery to browse for instances of a service type. Service discovery consumes network bandwidth and will continue until the application calls stopServiceDiscovery(DiscoveryListener).

The function call immediately returns after sending a request to start service discovery to the framework. The application is notified of a success to initiate discovery through the callback DiscoveryListener.onDiscoveryStarted or a failure through DiscoveryListener.onStartDiscoveryFailed.

Upon successful start, application is notified when a service is found with DiscoveryListener.onServiceFound or when a service is lost with DiscoveryListener.onServiceLost.

Upon failure to start, service discovery is not active and application does not need to invoke stopServiceDiscovery(DiscoveryListener)

The application should call stopServiceDiscovery(DiscoveryListener) when discovery of this service type is no longer required, and/or whenever the application is paused or stopped.

Android reference for android.net.nsd.NsdManager.discoverServices.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

DiscoverServices(String, NsdProtocol, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

[Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/nsd/NsdManager$DiscoveryListener;)V", "")]
public void DiscoverServices(string? serviceType, Android.Net.Nsd.NsdProtocol protocolType, Android.Net.Nsd.NsdManager.IDiscoveryListener? listener);
[<Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/nsd/NsdManager$DiscoveryListener;)V", "")>]
member this.DiscoverServices : string * Android.Net.Nsd.NsdProtocol * Android.Net.Nsd.NsdManager.IDiscoveryListener -> unit

Parameters

serviceType
String

The service type being discovered. Examples include "_http._tcp" for http services or "_ipp._tcp" for printers

protocolType
NsdProtocol

The service discovery protocol

listener
NsdManager.IDiscoveryListener

The listener notifies of a successful discovery and is used to stop discovery on this serviceType through a call on #stopServiceDiscovery. Cannot be null. Cannot be in use for an active service discovery.

Attributes

Remarks

Java documentation for android.net.nsd.NsdManager.discoverServices(java.lang.String, int, android.net.nsd.DiscoveryListener).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

DiscoverServices(String, NsdProtocol, Network, IExecutor, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

[Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/Network;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=33)]
public void DiscoverServices(string serviceType, Android.Net.Nsd.NsdProtocol protocolType, Android.Net.Network? network, Java.Util.Concurrent.IExecutor executor, Android.Net.Nsd.NsdManager.IDiscoveryListener listener);
[<Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/Network;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=33)>]
member this.DiscoverServices : string * Android.Net.Nsd.NsdProtocol * Android.Net.Network * Java.Util.Concurrent.IExecutor * Android.Net.Nsd.NsdManager.IDiscoveryListener -> unit

Parameters

serviceType
String

The service type being discovered. Examples include "_http._tcp" for http services or "_ipp._tcp" for printers. This value cannot be null.

protocolType
NsdProtocol

The service discovery protocol

network
Network

Network to discover services on, or null to discover on all available networks

executor
IExecutor

Executor to run listener callbacks with. This value cannot be null.

listener
NsdManager.IDiscoveryListener

The listener notifies of a successful discovery and is used to stop discovery on this serviceType through a call on stopServiceDiscovery(DiscoveryListener). This value cannot be null.

Attributes

Remarks

Initiate service discovery to browse for instances of a service type. Service discovery consumes network bandwidth and will continue until the application calls stopServiceDiscovery(DiscoveryListener).

The function call immediately returns after sending a request to start service discovery to the framework. The application is notified of a success to initiate discovery through the callback DiscoveryListener.onDiscoveryStarted or a failure through DiscoveryListener.onStartDiscoveryFailed.

Upon successful start, application is notified when a service is found with DiscoveryListener.onServiceFound or when a service is lost with DiscoveryListener.onServiceLost.

Upon failure to start, service discovery is not active and application does not need to invoke stopServiceDiscovery(DiscoveryListener)

The application should call stopServiceDiscovery(DiscoveryListener) when discovery of this service type is no longer required, and/or whenever the application is paused or stopped.

Android reference for android.net.nsd.NsdManager.discoverServices.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

DiscoverServices(String, NsdProtocol, NetworkRequest, IExecutor, NsdManager+IDiscoveryListener)

Initiate service discovery to browse for instances of a service type.

[Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/NetworkRequest;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=33)]
[Android.Runtime.RequiresPermission("android.permission.ACCESS_NETWORK_STATE")]
public void DiscoverServices(string serviceType, Android.Net.Nsd.NsdProtocol protocolType, Android.Net.NetworkRequest networkRequest, Java.Util.Concurrent.IExecutor executor, Android.Net.Nsd.NsdManager.IDiscoveryListener listener);
[<Android.Runtime.Register("discoverServices", "(Ljava/lang/String;ILandroid/net/NetworkRequest;Ljava/util/concurrent/Executor;Landroid/net/nsd/NsdManager$DiscoveryListener;)V", "", ApiSince=33)>]
[<Android.Runtime.RequiresPermission("android.permission.ACCESS_NETWORK_STATE")>]
member this.DiscoverServices : string * Android.Net.Nsd.NsdProtocol * Android.Net.NetworkRequest * Java.Util.Concurrent.IExecutor * Android.Net.Nsd.NsdManager.IDiscoveryListener -> unit

Parameters

serviceType
String

The service type being discovered. Examples include "_http._tcp" for http services or "_ipp._tcp" for printers. This value cannot be null.

protocolType
NsdProtocol

The service discovery protocol

networkRequest
NetworkRequest

Request specifying networks that should be considered when discovering. This value cannot be null.

executor
IExecutor

Executor to run listener callbacks with. This value cannot be null.

listener
NsdManager.IDiscoveryListener

The listener notifies of a successful discovery and is used to stop discovery on this serviceType through a call on stopServiceDiscovery(DiscoveryListener). This value cannot be null.

Attributes

Remarks

Initiate service discovery to browse for instances of a service type. Service discovery consumes network bandwidth and will continue until the application calls stopServiceDiscovery(DiscoveryListener).

The function call immediately returns after sending a request to start service discovery to the framework. The application is notified of a success to initiate discovery through the callback DiscoveryListener.onDiscoveryStarted or a failure through DiscoveryListener.onStartDiscoveryFailed.

Upon successful start, application is notified when a service is found with DiscoveryListener.onServiceFound or when a service is lost with DiscoveryListener.onServiceLost.

Upon failure to start, service discovery is not active and application does not need to invoke stopServiceDiscovery(DiscoveryListener)

The application should call stopServiceDiscovery(DiscoveryListener) when discovery of this service type is no longer required, and/or whenever the application is paused or stopped.

During discovery, new networks may connect or existing networks may disconnect - for example if wifi is reconnected. When a service was found on a network that disconnects, DiscoveryListener.onServiceLost will be called. If a new network connects that matches the NetworkRequest, DiscoveryListener.onServiceFound will be called for services found on that network. Applications that do not want to track networks themselves are encouraged to use this method instead of other overloads of discoverServices, as they will receive proper notifications when a service becomes available or unavailable due to network changes. Requires Manifest.permission.ACCESS_NETWORK_STATE

Android reference for android.net.nsd.NsdManager.discoverServices.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to