NsdServiceInfo
class NsdServiceInfo : Parcelable
kotlin.Any | |
↳ | android.net.nsd.NsdServiceInfo |
A class representing service information for network service discovery
Summary
Inherited constants | |
---|---|
Public constructors | |
---|---|
Public methods | |
---|---|
Int |
Implement the Parcelable interface |
MutableMap<String!, ByteArray!>! |
Retrieve attributes as a map of String keys to byte[] values. |
InetAddress! |
getHost() Get the host address. |
MutableList<InetAddress!> |
Get the host addresses. |
Network? |
Get the network where the service can be found. |
Int |
getPort() Get port number. |
String! |
Get the service name |
String! |
Get the service type |
MutableSet<String!> |
Returns subtypes of this service instance. |
Unit |
removeAttribute(key: String!) Remove an attribute by key |
Unit |
setAttribute(key: String!, value: String!) Add a service attribute as a key/value pair. |
Unit |
setHost(s: InetAddress!) Set the host address |
Unit |
setHostAddresses(addresses: MutableList<InetAddress!>) Set the host addresses. |
Unit |
setNetwork(network: Network?) Set the network where the service can be found. |
Unit |
Set port number |
Unit |
setServiceName(s: String!) Set the service name |
Unit |
setServiceType(s: String!) Set the service type |
Unit |
setSubtypes(subtypes: MutableSet<String!>) Sets the subtypes to be advertised for this service instance. |
String |
toString() |
Unit |
writeToParcel(dest: Parcel, flags: Int) Implement the Parcelable interface |
Properties | |
---|---|
static Parcelable.Creator<NsdServiceInfo!> |
Implement the Parcelable interface |
Public constructors
Public methods
describeContents
fun describeContents(): Int
Implement the Parcelable interface
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getAttributes
fun getAttributes(): MutableMap<String!, ByteArray!>!
Retrieve attributes as a map of String keys to byte[] values. The attributes map is only valid for a resolved service.
The returned map is unmodifiable; changes must be made through setAttribute
and removeAttribute
.
getHost
fungetHost(): InetAddress!
Deprecated: Use getHostAddresses()
to get the entire list of addresses for the host.
Get the host address. The host address is valid for a resolved service.
getHostAddresses
fun getHostAddresses(): MutableList<InetAddress!>
Get the host addresses. All host addresses are valid for the resolved service. All addresses share the same port
Return | |
---|---|
MutableList<InetAddress!> |
This value cannot be null . |
See Also
getNetwork
fun getNetwork(): Network?
Get the network where the service can be found. This is set if this NsdServiceInfo
was obtained from android.net.nsd.NsdManager#discoverServices or android.net.nsd.NsdManager#resolveService, unless the service was found on a network interface that does not have a Network
(such as a tethering downstream, where services are advertised from devices connected to this device via tethering).
Return | |
---|---|
Network? |
This value may be null . |
getPort
fun getPort(): Int
Get port number. The port number is valid for a resolved service. The port is valid for all addresses.
See Also
getSubtypes
fun getSubtypes(): MutableSet<String!>
Returns subtypes of this service instance. When this object is returned by the service discovery/browse APIs (etc. NsdManager.DiscoveryListener
), the return value may or may not include the subtypes of this service.
Return | |
---|---|
MutableSet<String!> |
This value cannot be null . |
removeAttribute
fun removeAttribute(key: String!): Unit
Remove an attribute by key
setAttribute
fun setAttribute(
key: String!,
value: String!
): Unit
Add a service attribute as a key/value pair.
Service attributes are included as DNS-SD TXT record pairs.
The key must be US-ASCII printable characters, excluding the '=' character. Values may be UTF-8 strings or null. The total length of key + value must be less than 255 bytes.
Keys should be short, ideally no more than 9 characters, and unique per instance of NsdServiceInfo
. Calling setAttribute
twice with the same key will overwrite first value.
setHost
funsetHost(s: InetAddress!): Unit
Deprecated: Use setHostAddresses(java.util.List)
to set multiple addresses for the host.
Set the host address
setHostAddresses
fun setHostAddresses(addresses: MutableList<InetAddress!>): Unit
Set the host addresses.
When registering hosts/services, there can only be one registration including address records for a given hostname.
For example, if a client registers a service with the hostname "MyHost" and the address records of 192.168.1.1 and 192.168.1.2, then other registrations for the hostname "MyHost" must not have any address record, otherwise there will be a conflict.
Parameters | |
---|---|
addresses |
MutableList<InetAddress!>: This value cannot be null . |
setNetwork
fun setNetwork(network: Network?): Unit
Set the network where the service can be found.
Parameters | |
---|---|
network |
Network?: The network, or null to search for, or to announce, the service on all connected networks. |
setSubtypes
fun setSubtypes(subtypes: MutableSet<String!>): Unit
Sets the subtypes to be advertised for this service instance. The elements in subtypes
should be the subtype identifiers which have the trailing "._sub" removed. For example, the subtype should be "_printer" for "_printer._sub._http._tcp.local". Only one subtype will be registered if multiple elements of subtypes
have the same case-insensitive value.
Parameters | |
---|---|
subtypes |
MutableSet<String!>: This value cannot be null . |
toString
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Implement the Parcelable interface
Parameters | |
---|---|
dest |
Parcel: The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Properties
CREATOR
static val CREATOR: Parcelable.Creator<NsdServiceInfo!>
Implement the Parcelable interface