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!

Get the host address.

MutableList<InetAddress!>

Get the host addresses.

Network?

Get the network where the service can be found.

Int

Get port number.

String!

Get the service name

String!

Get the service type

MutableSet<String!>

Returns subtypes of this service instance.

Unit

Remove an attribute by key

Unit
setAttribute(key: String!, value: String!)

Add a service attribute as a key/value pair.

Unit

Set the host address

Unit

Set the host addresses

Unit
setNetwork(network: Network?)

Set the network where the service can be found.

Unit

Set port number

Unit

Set the service name

Unit

Set the service type

Unit

Sets the subtypes to be advertised for this service instance.

String

Unit
writeToParcel(dest: Parcel, flags: Int)

Implement the Parcelable interface

Properties
static Parcelable.Creator<NsdServiceInfo!>

Implement the Parcelable interface

Public constructors

NsdServiceInfo

NsdServiceInfo()

Public methods

describeContents

Added in API level 16
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

Added in API level 16
Also in T Extensions 3
Deprecated in API level 34
fun getHost(): 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.

getServiceName

fun getServiceName(): String!

Get the service name

getServiceType

fun getServiceType(): String!

Get the service type

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

Added in API level 16
Also in T Extensions 3
Deprecated in API level 34
fun setHost(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

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.

setPort

fun setPort(p: Int): Unit

Set port number

setServiceName

fun setServiceName(s: String!): Unit

Set the service name

setServiceType

fun setServiceType(s: String!): Unit

Set the service type

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

Added in API level 16
fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 16
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