NsdServiceInfo.SetAttribute Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| SetAttribute(String, Byte[]) |
Add a service attribute as a key/value pair using raw bytes. |
| SetAttribute(String, String) |
Add a service attribute as a key/value pair. |
SetAttribute(String, Byte[])
Add a service attribute as a key/value pair using raw bytes.
[Android.Runtime.Register("setAttribute", "(Ljava/lang/String;[B)V", "", ApiSince=37)]
public void SetAttribute(string key, byte[]? value);
[<Android.Runtime.Register("setAttribute", "(Ljava/lang/String;[B)V", "", ApiSince=37)>]
member this.SetAttribute : string * byte[] -> unit
Parameters
- key
- String
the key of the attribute
- value
- Byte[]
the raw bytes of the attribute value, or null for an attribute with no value
- Attributes
Remarks
Add a service attribute as a key/value pair using raw bytes.
Service attributes are included as DNS-SD TXT record pairs.
This method preserves the provided bytes exactly, ensuring that data is maintained even if the bytes do not represent a valid UTF-8 string.
The key must be US-ASCII printable characters, excluding the '=' character. 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(String, byte) twice with the same key will overwrite the previous value.
Android reference for android.net.nsd.NsdServiceInfo.setAttribute.
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
SetAttribute(String, String)
Add a service attribute as a key/value pair.
[Android.Runtime.Register("setAttribute", "(Ljava/lang/String;Ljava/lang/String;)V", "")]
public void SetAttribute(string? key, string? value);
[<Android.Runtime.Register("setAttribute", "(Ljava/lang/String;Ljava/lang/String;)V", "")>]
member this.SetAttribute : string * string -> unit
Parameters
- key
- String
- value
- String
- Attributes
Remarks
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.
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.