Stay organized with collections
Save and categorize content based on your preferences.
Builder
class Builder
The builder for creating new DiscoveryRequest
objects.
Summary
Public constructors |
Creates a new default Builder object with given service type.
|
Public constructors
Builder
Builder(serviceType: String)
Creates a new default Builder
object with given service type.
Parameters |
serviceType |
String: This value cannot be null . |
Exceptions |
java.lang.IllegalArgumentException |
if serviceType is null or an empty string |
Public methods
setNetwork
fun setNetwork(network: Network?): DiscoveryRequest.Builder
Sets the Network
on which the discovery queries should be sent.
Parameters |
network |
Network?: the discovery network or null if the query should be sent on all supported networks |
setSubtype
fun setSubtype(subtype: String?): DiscoveryRequest.Builder
Sets the optional subtype of the services to be discovered. If a non-empty subtype
is specified, it must start with underscore ('_') and have the trailing "._sub" removed. Otherwise, android.net.nsd.NsdManager#discoverServices will fail with android.net.nsd.NsdManager#FAILURE_BAD_PARAMETER. For example, subtype
should be "_printer" for DNS name "_printer._sub._http._tcp". In this case, only services with this subtype
will be queried, rather than all services of the base service type. Note that a non-empty service type must be specified with #setServiceType if a non-empty subtype is specified by this method.
Parameters |
subtype |
String?: This value may 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.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# DiscoveryRequest.Builder\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 12](https://developer.android.com/sdkExtensions)\n\nBuilder\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/nsd/DiscoveryRequest.Builder \"View this page in Java\") \n\n```\nclass Builder\n```\n\n|---|-----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.net.nsd.DiscoveryRequest.Builder](#) |\n\nThe builder for creating new [DiscoveryRequest](/reference/kotlin/android/net/nsd/DiscoveryRequest) objects.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Builder](#Builder(kotlin.String))`(`serviceType:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Creates a new default [Builder](#) object with given service type. |\n\n| Public methods ||\n|------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [DiscoveryRequest](/reference/kotlin/android/net/nsd/DiscoveryRequest) | [build](#build())`()` Creates a new [DiscoveryRequest](/reference/kotlin/android/net/nsd/DiscoveryRequest) object. |\n| [DiscoveryRequest.Builder](#) | [setNetwork](#setNetwork(android.net.Network))`(`network:` `[Network](../Network.html#)?`)` Sets the [Network](../Network.html#) on which the discovery queries should be sent. |\n| [DiscoveryRequest.Builder](#) | [setSubtype](#setSubtype(kotlin.String))`(`subtype:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets the optional subtype of the services to be discovered. |\n\nPublic constructors\n-------------------\n\n### Builder\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 12](https://developer.android.com/sdkExtensions) \n\n```\nBuilder(serviceType: String)\n```\n\nCreates a new default [Builder](#) object with given service type.\n\n| Parameters ||\n|---------------|----------------------------------------------------------------------------------------------------------------|\n| `serviceType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): This value cannot be `null`. |\n\n| Exceptions ||\n|--------------------------------------|-----------------------------------------------|\n| `java.lang.IllegalArgumentException` | if `serviceType` is `null` or an empty string |\n\nPublic methods\n--------------\n\n### build\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 12](https://developer.android.com/sdkExtensions) \n\n```\nfun build(): DiscoveryRequest\n```\n\nCreates a new [DiscoveryRequest](/reference/kotlin/android/net/nsd/DiscoveryRequest) object.\n\n| Return ||\n|------------------------------------------------------------------------|------------------------------|\n| [DiscoveryRequest](/reference/kotlin/android/net/nsd/DiscoveryRequest) | This value cannot be `null`. |\n\n### setNetwork\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 12](https://developer.android.com/sdkExtensions) \n\n```\nfun setNetwork(network: Network?): DiscoveryRequest.Builder\n```\n\nSets the [Network](../Network.html#) on which the discovery queries should be sent.\n\n| Parameters ||\n|-----------|---------------------------------------------------------------------------------------------------------------------|\n| `network` | [Network](../Network.html#)?: the discovery network or `null` if the query should be sent on all supported networks |\n\n| Return ||\n|-------------------------------|------------------------------|\n| [DiscoveryRequest.Builder](#) | This value cannot be `null`. |\n\n### setSubtype\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nAlso in [T Extensions 12](https://developer.android.com/sdkExtensions) \n\n```\nfun setSubtype(subtype: String?): DiscoveryRequest.Builder\n```\n\nSets the optional subtype of the services to be discovered. If a non-empty `subtype` is specified, it must start with underscore ('_') and have the trailing \"._sub\" removed. Otherwise, android.net.nsd.NsdManager#discoverServices will fail with android.net.nsd.NsdManager#FAILURE_BAD_PARAMETER. For example, `subtype` should be \"_printer\" for DNS name \"_printer._sub._http._tcp\". In this case, only services with this `subtype` will be queried, rather than all services of the base service type. Note that a non-empty service type must be specified with #setServiceType if a non-empty subtype is specified by this method.\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------------------|\n| `subtype` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?: This value may be `null`. |\n\n| Return ||\n|-------------------------------|------------------------------|\n| [DiscoveryRequest.Builder](#) | This value cannot be `null`. |"]]