# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# WifiAwareNetworkSpecifier.Builder

`public static final class WifiAwareNetworkSpecifier.Builder`
`extends Object` ``

java.lang.Object
↳ | android.net.wifi.aware.WifiAwareNetworkSpecifier.Builder

A builder class for a Wi-Fi Aware network specifier to set up an Aware connection with a peer.

## Summary

### Public constructors
`Builder(DiscoverySession discoverySession, PeerHandle peerHandle)` Create a builder for `WifiAwareNetworkSpecifier` used in requests to set up a Wi-Fi Aware connection with a peer.

### Public methods
`WifiAwareNetworkSpecifier` | `build()` Create a `NetworkRequest.Builder.setNetworkSpecifier(NetworkSpecifier)` for a WiFi Aware connection (link) to the specified peer.
`WifiAwareNetworkSpecifier.Builder` | `setPmk(byte[] pmk)` Configure the PMK for the Wi-Fi Aware connection being requested.
`WifiAwareNetworkSpecifier.Builder` | `setPort(int port)` Configure the port number which will be used to create a connection over this link.
`WifiAwareNetworkSpecifier.Builder` | `setPskPassphrase(String pskPassphrase)` Configure the PSK Passphrase for the Wi-Fi Aware connection being requested.
`WifiAwareNetworkSpecifier.Builder` | `setTransportProtocol(int transportProtocol)` Configure the transport protocol which will be used to create a connection over this link.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder (DiscoverySession discoverySession,
                    PeerHandle peerHandle)

Create a builder for `WifiAwareNetworkSpecifier` used in requests to set up a Wi-Fi Aware connection with a peer.

Parameters
`discoverySession` | `DiscoverySession`: A Wi-Fi Aware discovery session in whose context the connection is created. This value cannot be `null`.
`peerHandle` | `PeerHandle`: The handle of the peer to which the Wi-Fi Aware connection is requested. The peer is discovered through Wi-Fi Aware discovery. The handle can be obtained through `DiscoverySessionCallback#onServiceDiscovered(PeerHandle, byte[], java.util.List)` or `DiscoverySessionCallback#onMessageReceived(PeerHandle, byte[])`. This value cannot be `null`.

## Public methods

### build

    public WifiAwareNetworkSpecifier build ()

Create a `NetworkRequest.Builder.setNetworkSpecifier(NetworkSpecifier)` for a WiFi Aware connection (link) to the specified peer. The `NetworkRequest.Builder.addTransportType(int)` should be set to `NetworkCapabilities.TRANSPORT_WIFI_AWARE`.

The default builder constructor will initialize a NetworkSpecifier which requests an open (non-encrypted) link. To request an encrypted link use the `setPskPassphrase(java.lang.String)` or `setPmk(byte[])` builder methods.

Returns
`WifiAwareNetworkSpecifier` | A `NetworkSpecifier` to be used to construct `NetworkRequest.Builder.setNetworkSpecifier(NetworkSpecifier)` to pass to `ConnectivityManager.requestNetwork(android.net.NetworkRequest, android.net.ConnectivityManager.NetworkCallback)` [or other varieties of that API]. This value cannot be `null`.

### setPmk

    public WifiAwareNetworkSpecifier.Builder setPmk (byte[] pmk)

Configure the PMK for the Wi-Fi Aware connection being requested. This method is optional - if not called, then an Open (unencrypted) connection will be created.

Parameters
`pmk` | `byte`: A PMK (pairwise master key, see IEEE 802.11i) specifying the key to use for encrypting the data-path. Use the `setPskPassphrase(java.lang.String)` to specify a Passphrase. This value cannot be `null`.

Returns
`WifiAwareNetworkSpecifier.Builder` | the current `Builder` builder, enabling chaining of builder methods. This value cannot be `null`.

### setPort

    public WifiAwareNetworkSpecifier.Builder setPort (int port)

Configure the port number which will be used to create a connection over this link. This configuration should only be done on the server device, e.g. the device creating the `ServerSocket`.

Notes:

- The server device must be the Publisher device!
- The port information can only be specified on secure links, specified using `setPskPassphrase(java.lang.String)` or `setPmk(byte[])`.

Parameters
`port` | `int`: A positive integer indicating the port to be used for communication. Value is between 0 and 65535 inclusive

Returns
`WifiAwareNetworkSpecifier.Builder` | the current `Builder` builder, enabling chaining of builder methods. This value cannot be `null`.

### setPskPassphrase

    public WifiAwareNetworkSpecifier.Builder setPskPassphrase (String pskPassphrase)

Configure the PSK Passphrase for the Wi-Fi Aware connection being requested. This method is optional - if not called, then an Open (unencrypted) connection will be created.

Parameters
`pskPassphrase` | `String`: The (optional) passphrase to be used to encrypt the link. Use the `setPmk(byte[])` to specify a PMK. This value cannot be `null`.

Returns
`WifiAwareNetworkSpecifier.Builder` | the current `Builder` builder, enabling chaining of builder methods. This value cannot be `null`.

### setTransportProtocol

    public WifiAwareNetworkSpecifier.Builder setTransportProtocol (int transportProtocol)

Configure the transport protocol which will be used to create a connection over this link. This configuration should only be done on the server device, e.g. the device creating the `ServerSocket` for TCP.

Notes:

- The server device must be the Publisher device!
- The transport protocol information can only be specified on secure links, specified using `setPskPassphrase(java.lang.String)` or `setPmk(byte[])`.

The transport protocol number is assigned by the Internet Assigned Numbers Authority (IANA) https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml.

Parameters
`transportProtocol` | `int`: The transport protocol to be used for communication. Value is between 0 and 255 inclusive

Returns
`WifiAwareNetworkSpecifier.Builder` | the current `Builder` builder, enabling chaining of builder methods. This value cannot be `null`.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*