Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#constants) \| [Methods](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#inhmethods)

# WifiAwareManager

*** ** * ** ***

` public class WifiAwareManager `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.wifi.aware.WifiAwareManager |

<br />

*** ** * ** ***

This class provides the primary API for managing Wi-Fi Aware operations: discovery and peer-to-peer data connections.

The class provides access to:

- Initialize a Aware cluster (peer-to-peer synchronization). Refer to `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)`.
- Create discovery sessions (publish or subscribe sessions). Refer to `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` and `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)`.
- Create a Aware network specifier to be used with `https://developer.android.com/reference/android/net/ConnectivityManager#requestNetwork(android.net.NetworkRequest,%20android.net.ConnectivityManager.NetworkCallback)` to set-up a Aware connection with a peer. Refer to `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder`.

Aware may not be usable when Wi-Fi is disabled (and other conditions). To validate that the functionality is available use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isAvailable()` function. To track changes in Aware usability register for the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_STATE_CHANGED` broadcast. Note that this broadcast is not sticky - you should register for it and then check the above API to avoid a race condition.

An application must use `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)` to initialize a Aware cluster - before making any other Aware operation. Aware cluster membership is a device-wide operation - the API guarantees that the device is in a cluster or joins a Aware cluster (or starts one if none can be found). Information about attach success (or failure) are returned in callbacks of `https://developer.android.com/reference/android/net/wifi/aware/AttachCallback`. Proceed with Aware discovery or connection setup only after receiving confirmation that Aware attach succeeded - `https://developer.android.com/reference/android/net/wifi/aware/AttachCallback#onAttached(android.net.wifi.aware.WifiAwareSession)`. When an application is finished using Aware it **must** use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#close()` API to indicate to the Aware service that the device may detach from the Aware cluster. The device will actually disable Aware once the last application detaches.

Once a Aware attach is confirmed use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` or `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` to create publish or subscribe Aware discovery sessions. Events are called on the provided callback object `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback`. Specifically, the `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPublishStarted(android.net.wifi.aware.PublishDiscoverySession)` and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSubscribeStarted(android.net.wifi.aware.SubscribeDiscoverySession)` return `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession` and `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession` objects respectively on which additional session operations can be performed, e.g. updating the session `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig)` and `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)`. Sessions can also be used to send messages using the `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])` APIs. When an application is finished with a discovery session it **must** terminate it using the `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#close()` API.

Creating connections between Aware devices is managed by the standard `https://developer.android.com/reference/android/net/ConnectivityManager#requestNetwork(android.net.NetworkRequest,%20android.net.ConnectivityManager.NetworkCallback)`. The `https://developer.android.com/reference/android/net/NetworkRequest` object should be constructed with:

- `https://developer.android.com/reference/android/net/NetworkRequest.Builder#addTransportType(int)` of `https://developer.android.com/reference/android/net/NetworkCapabilities#TRANSPORT_WIFI_AWARE`.
- `https://developer.android.com/reference/android/net/NetworkRequest.Builder#setNetworkSpecifier(java.lang.String)` using `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder`.

.   
Restricted for SDK Runtime environment in API level 34.

<br />

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_RESOURCE_CHANGED` Intent broadcast sent whenever Wi-Fi Aware resource availability has changed. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_STATE_CHANGED` Broadcast intent action to indicate that the state of Wi-Fi Aware availability has changed and all active Aware sessions are no longer usable. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#EXTRA_AWARE_RESOURCES` Sent as a part of `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_RESOURCE_CHANGED` that contains an instance of `https://developer.android.com/reference/android/net/wifi/aware/AwareResources` representing the current Wi-Fi Aware resources. |
| `int` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_INITIATOR` Connection creation role is that of INITIATOR. |
| `int` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_RESPONDER` Connection creation role is that of RESPONDER. |
| `int` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE` Reason code provided in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceLost(android.net.wifi.aware.PeerHandle,%20int)` indicating that the service advertised by the peer is no longer visible. |
| `int` | `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN` Reason code provided in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceLost(android.net.wifi.aware.PeerHandle,%20int)` indicating that the service was lost for unknown reason. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)(https://developer.android.com/reference/android/net/wifi/aware/AttachCallback attachCallback, https://developer.android.com/reference/android/os/Handler handler) ` Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)(https://developer.android.com/reference/android/net/wifi/aware/AttachCallback attachCallback, https://developer.android.com/reference/android/net/wifi/aware/IdentityChangedListener identityChangedListener, https://developer.android.com/reference/android/os/Handler handler) ` Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers. |
| ` static https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#createTxtRecordMap(byte[])(byte[] txtRecordTlvBuffer) ` Create the TXT record map from the TLV buffer which generate by `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#createTxtRecordTlvBuffer(java.util.Map<java.lang.String,java.lang.String>)` |
| ` static byte[]` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#createTxtRecordTlvBuffer(java.util.Map<java.lang.String,java.lang.String>)(https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String> txtRecord) ` Create the TLV buffer containing the TXT record as per the Wi-Fi Aware specifications 4.0 Table 150. |
| ` https://developer.android.com/reference/android/net/wifi/aware/AwareResources` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#getAvailableAwareResources()() ` Return the available resources of the Wi-Fi aware service: a set of parameters which specify limitations on service usage, e.g the number of data-paths which could be created. |
| ` https://developer.android.com/reference/android/net/wifi/aware/Characteristics` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#getCharacteristics()() ` Returns the characteristics of the Wi-Fi Aware interface: a set of parameters which specify limitations on configurations, e.g. the maximum service name length. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#getPairedDevices(java.util.concurrent.Executor,%20java.util.function.Consumer<java.util.List<java.lang.String>>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>> resultsCallback) ` Get all the paired devices configured by the calling app. |
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isAvailable()() ` Returns the current status of Aware API: whether or not Aware is available. |
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isDeviceAttached()() ` Return the current status of the Aware service: whether or not the device is already attached to an Aware cluster. |
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isInstantCommunicationModeEnabled()() ` Return the current status of the Wifi Aware instant communication mode. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isOpportunisticModeEnabled(java.util.concurrent.Executor,%20java.util.function.Consumer<java.lang.Boolean>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/java/lang/Boolean> resultsCallback) ` Indicate whether all Wi-Fi Aware sessions created by the calling app are opportunistic as defined and configured by `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#setOpportunisticModeEnabled(boolean)` Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE` |
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isSetChannelOnDataPathSupported()() ` Return the device support for setting a channel requirement in a data-path request. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#removePairedDevice(java.lang.String)(https://developer.android.com/reference/java/lang/String alias) ` Remove the target paired device setup by the caller by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` Requires `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE` |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#resetPairedDevices()() ` Reset all paired devices setup by the caller by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` Requires `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE` |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#setOpportunisticModeEnabled(boolean)(boolean enabled) ` Set all Wi-Fi Aware sessions created by the calling app to be opportunistic. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### ACTION_WIFI_AWARE_RESOURCE_CHANGED

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_WIFI_AWARE_RESOURCE_CHANGED
```

Intent broadcast sent whenever Wi-Fi Aware resource availability has changed. The resources are attached with the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#EXTRA_AWARE_RESOURCES` extra. The resources can also be obtained using the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#getAvailableAwareResources()` method. To receive this broadcast, apps must hold `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`.

Note: The broadcast is only delivered to registered receivers - no manifest registered components will be launched.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

Constant Value: "android.net.wifi.aware.action.WIFI_AWARE_RESOURCE_CHANGED"

### ACTION_WIFI_AWARE_STATE_CHANGED

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_WIFI_AWARE_STATE_CHANGED
```

Broadcast intent action to indicate that the state of Wi-Fi Aware availability has changed and all active Aware sessions are no longer usable. Use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isAvailable()` to query the current status. This broadcast is **not** sticky, use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#isAvailable()` API after registering the broadcast to check the current state of Wi-Fi Aware.

Note: The broadcast is only delivered to registered receivers - no manifest registered components will be launched.

<br />

Constant Value: "android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED"

### EXTRA_AWARE_RESOURCES

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_AWARE_RESOURCES
```

Sent as a part of `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_RESOURCE_CHANGED` that contains an instance of `https://developer.android.com/reference/android/net/wifi/aware/AwareResources` representing the current Wi-Fi Aware resources.

<br />

Constant Value: "android.net.wifi.aware.extra.AWARE_RESOURCES"

### WIFI_AWARE_DATA_PATH_ROLE_INITIATOR

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
```

Connection creation role is that of INITIATOR. Used to create a network specifier string when requesting a Aware network.

<br />

**See also:**

- `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#createNetworkSpecifierOpen(int,%20byte[])`
- `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#createNetworkSpecifierPassphrase(int,%20byte[],%20java.lang.String)`

Constant Value: 0 (0x00000000)

### WIFI_AWARE_DATA_PATH_ROLE_RESPONDER

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER
```

Connection creation role is that of RESPONDER. Used to create a network specifier string when requesting a Aware network.

<br />

**See also:**

- `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#createNetworkSpecifierOpen(int,%20byte[])`
- `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#createNetworkSpecifierPassphrase(int,%20byte[],%20java.lang.String)`

Constant Value: 1 (0x00000001)

### WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE
```

Reason code provided in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceLost(android.net.wifi.aware.PeerHandle,%20int)` indicating that the service advertised by the peer is no longer visible. This may be because the peer is out of range or because the peer stopped advertising this service.

<br />

Constant Value: 1 (0x00000001)

### WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN
```

Reason code provided in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceLost(android.net.wifi.aware.PeerHandle,%20int)` indicating that the service was lost for unknown reason.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### attach

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void attach (AttachCallback attachCallback, 
                Handler handler)
```

Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers. The device will attach to an existing cluster if it can find one or create a new cluster (if it is the first to enable Aware in its vicinity). Results (e.g. successful attach to a cluster) are provided to the `attachCallback` object. An application **must** call `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#close()` when done with the Wi-Fi Aware object.

Note: a Aware cluster is a shared resource - if the device is already attached to a cluster then this function will simply indicate success immediately using the same `attachCallback`.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE` and `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE`

<br />

| Parameters ||
|---|---|
| `attachCallback` | `AttachCallback`: A callback for attach events, extended from `https://developer.android.com/reference/android/net/wifi/aware/AttachCallback`. This value cannot be `null`. <br /> |
| `handler` | `Handler`: The Handler on whose thread to execute the callbacks of the `attachCallback` object. If a null is provided then the application's main thread will be used. <br /> |

### attach

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void attach (AttachCallback attachCallback, 
                IdentityChangedListener identityChangedListener, 
                Handler handler)
```

Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers. The device will attach to an existing cluster if it can find one or create a new cluster (if it is the first to enable Aware in its vicinity). Results (e.g. successful attach to a cluster) are provided to the `attachCallback` object. An application **must** call `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#close()` when done with the Wi-Fi Aware object.

Note: a Aware cluster is a shared resource - if the device is already attached to a cluster then this function will simply indicate success immediately using the same `attachCallback`.

This version of the API attaches a listener to receive the MAC address of the Aware interface on startup and whenever it is updated (it is randomized at regular intervals for privacy). If targeting `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU` or later, the application must have `https://developer.android.com/reference/android/Manifest.permission#NEARBY_WIFI_DEVICES` with android:usesPermissionFlags="neverForLocation". If the application does not declare android:usesPermissionFlags="neverForLocation", then it must also have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`. If targeting an earlier release than `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`, the application must have `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION`. Apps without `https://developer.android.com/reference/android/Manifest.permission#NEARBY_WIFI_DEVICES` or `https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION` can use the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)` version. Note that aside from permission requirements the `https://developer.android.com/reference/android/net/wifi/aware/IdentityChangedListener` will wake up the host at regular intervals causing higher power consumption, do not use it unless the information is necessary (e.g. for out-of-band discovery).

<br />

| Parameters ||
|---|---|
| `attachCallback` | `AttachCallback`: A callback for attach events, extended from `https://developer.android.com/reference/android/net/wifi/aware/AttachCallback`. This value cannot be `null`. <br /> |
| `identityChangedListener` | `IdentityChangedListener`: A callback for changed identity or cluster ID, extended from `https://developer.android.com/reference/android/net/wifi/aware/IdentityChangedListener`. This value cannot be `null`. <br /> |
| `handler` | `Handler`: The Handler on whose thread to execute the callbacks of the `attachCallback` and `identityChangedListener` objects. If a null is provided then the application's main thread will be used. <br /> |

### createTxtRecordMap

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Map<String, String> createTxtRecordMap (byte[] txtRecordTlvBuffer)
```

Create the TXT record map from the TLV buffer which generate by `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#createTxtRecordTlvBuffer(java.util.Map<java.lang.String,java.lang.String>)`

<br />

| Parameters ||
|---|---|
| `txtRecordTlvBuffer` | `byte`: The TLV buffer containing the TXT record. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Map<https://developer.android.com/reference/java/lang/String, https://developer.android.com/reference/java/lang/String>` | The TXT record map. This value cannot be `null`. <br /> |

### createTxtRecordTlvBuffer

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static byte[] createTxtRecordTlvBuffer (Map<String, String> txtRecord)
```

Create the TLV buffer containing the TXT record as per the Wi-Fi Aware specifications 4.0 Table 150.

<br />

| Parameters ||
|---|---|
| `txtRecord` | `Map`: txtMap TXT record with key/value pair in a map confirming to format defined at http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `byte[]` | The TLV buffer containing the TXT record. This value cannot be `null`. <br /> |

### getAvailableAwareResources

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AwareResources getAvailableAwareResources ()
```

Return the available resources of the Wi-Fi aware service: a set of parameters which specify limitations on service usage, e.g the number of data-paths which could be created.

May return `null` if the Wi-Fi Aware service is not initialized. Use `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)` or `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)` to initialize the Wi-Fi Aware service.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/AwareResources` | An object specifying the currently available resource of the Wi-Fi Aware service. <br /> |

### getCharacteristics

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Characteristics getCharacteristics ()
```

Returns the characteristics of the Wi-Fi Aware interface: a set of parameters which specify limitations on configurations, e.g. the maximum service name length.

May return `null` if the Wi-Fi Aware service is not initialized. Use `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)` or `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)` to initialize the Wi-Fi Aware service.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/Characteristics` | An object specifying configuration limitations of Aware. <br /> |

### getPairedDevices

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void getPairedDevices (Executor executor, 
                Consumer<List<String>> resultsCallback)
```

Get all the paired devices configured by the calling app.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor on which callback will be invoked. This value cannot be `null`. <br /> |
| `resultsCallback` | `Consumer`: An asynchronous callback that will return a list of paired devices' alias. This value cannot be `null`. <br /> |

### isAvailable

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAvailable ()
```

Returns the current status of Aware API: whether or not Aware is available. To track changes in the state of Aware API register for the `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#ACTION_WIFI_AWARE_STATE_CHANGED` broadcast.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `boolean` | A boolean indicating whether the app can use the Aware API at this time (true) or not (false). <br /> |

### isDeviceAttached

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isDeviceAttached ()
```

Return the current status of the Aware service: whether or not the device is already attached to an Aware cluster. To attach to an Aware cluster, please use `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.os.Handler)` or `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler)`.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `boolean` | A boolean indicating whether the device is attached to a cluster at this time (true) or not (false). <br /> |

### isInstantCommunicationModeEnabled

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isInstantCommunicationModeEnabled ()
```

Return the current status of the Wifi Aware instant communication mode. If the device doesn't support this feature, return will always be false.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `boolean` | true if it is enabled, false otherwise. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/wifi/aware/Characteristics#isInstantCommunicationModeSupported()`

### isOpportunisticModeEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void isOpportunisticModeEnabled (Executor executor, 
                Consumer<Boolean> resultsCallback)
```

Indicate whether all Wi-Fi Aware sessions created by the calling app are opportunistic as defined and configured by `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#setOpportunisticModeEnabled(boolean)`   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: The executor on which callback will be invoked. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `resultsCallback` | `Consumer`: An asynchronous callback that will return boolean. This value cannot be `null`. <br /> |

### isSetChannelOnDataPathSupported

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isSetChannelOnDataPathSupported ()
```

Return the device support for setting a channel requirement in a data-path request. If true the channel set by `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder#setChannelFrequencyMhz(int,%20boolean)` will be honored, otherwise it will be ignored.   

Requires `https://developer.android.com/reference/android/Manifest.permission#ACCESS_WIFI_STATE`

<br />

| Returns ||
|---|---|
| `boolean` | True is the device support set channel on data-path request, false otherwise. <br /> |

### removePairedDevice

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removePairedDevice (String alias)
```

Remove the target paired device setup by the caller by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)`   

Requires `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE`

<br />

| Parameters ||
|---|---|
| `alias` | `String`: The alias set by the caller. This value cannot be `null`. <br /> |

### resetPairedDevices

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void resetPairedDevices ()
```

Reset all paired devices setup by the caller by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)`   

Requires `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE`

<br />

### setOpportunisticModeEnabled

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setOpportunisticModeEnabled (boolean enabled)
```

Set all Wi-Fi Aware sessions created by the calling app to be opportunistic. Opportunistic Wi-Fi Aware sessions are considered low priority and may be torn down (the sessions or the Aware interface) if there are resource conflicts.   

Requires `https://developer.android.com/reference/android/Manifest.permission#CHANGE_WIFI_STATE`

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean`: True to configure all Wi-Fi Aware sessions by the calling app as Opportunistic. False by default. <br /> |