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

# DiscoverySessionCallback

*** ** * ** ***

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

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

<br />

*** ** * ** ***

Base class for Aware session events callbacks. Should be extended by applications wanting notifications. The callbacks are set when a publish or subscribe session is created using `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)`.

A single callback is set at session creation - it cannot be replaced.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#DiscoverySessionCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onBootstrappingFailed(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) ` Callback indicating that a Bootstrapping method negotiation failed. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onBootstrappingSucceeded(android.net.wifi.aware.PeerHandle,%20int,%20byte[])(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int method, byte[] message) ` Callback indicating that a Bootstrapping method negotiation succeeded. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onBootstrappingSucceeded(android.net.wifi.aware.PeerHandle,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int method) ` Callback indicating that a Bootstrapping method negotiation succeeded. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathConnected(android.net.wifi.aware.PeerHandle,%20android.net.wifi.aware.WifiAwareNetworkInfo)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkInfo info) ` Callback indicating that a data path has been connected. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathDisconnected(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) ` Callback indicating that a data path has been disconnected. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathRequestFailed(android.net.wifi.aware.PeerHandle,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int reason) ` Callback indicating that a data path request has failed. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathRequestReceived(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) ` Callback indicating that a data path request has been received. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onMessageReceived(android.net.wifi.aware.PeerHandle,%20byte[])(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, byte[] message) ` Called when a message is received from a discovery session peer - in response to the peer's `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])`. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onMessageSendFailed(int)(int messageId) ` Called when message transmission initiated with `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])` fails. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onMessageSendSucceeded(int)(int messageId) ` Called in response to `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])` when a message is transmitted successfully - i.e. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPairingSetupFailed(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) ` Callback indicating that a pairing setup process failed. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPairingSetupRequestReceived(android.net.wifi.aware.PeerHandle,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int requestId) ` Callback indicating that a pairing request is received from peer. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPairingSetupSucceeded(android.net.wifi.aware.PeerHandle,%20java.lang.String)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/java/lang/String alias) ` Callback indicating that a pairing setup process succeeded. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPairingVerificationFailed(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) ` Callback indicating that a pairing verification process failed. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPairingVerificationSucceed(android.net.wifi.aware.PeerHandle,%20java.lang.String)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/java/lang/String alias) ` Callback indicating that a pairing verification process succeeded. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPublishStarted(android.net.wifi.aware.PublishDiscoverySession)(https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession session) ` Called when a publish operation is started successfully in response to a `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` operation. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, byte[] serviceSpecificInfo, https://developer.android.com/reference/java/util/List<byte[]> matchFilter) ` Called when a subscribe operation results in a service discovery. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.ServiceDiscoveryInfo)(https://developer.android.com/reference/android/net/wifi/aware/ServiceDiscoveryInfo info) ` Called when a subscribe operation results in a service discovery. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.ServiceDiscoveryInfo,%20int)(https://developer.android.com/reference/android/net/wifi/aware/ServiceDiscoveryInfo info, int distanceMm) ` Called when a subscribe operation results in a service discovery. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, byte[] serviceSpecificInfo, https://developer.android.com/reference/java/util/List<byte[]> matchFilter, int distanceMm) ` Called when a subscribe operation results in a service discovery. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceLost(android.net.wifi.aware.PeerHandle,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int reason) ` Called when the discovered service is not available. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionConfigFailed()() ` Called when a publish or subscribe discovery session cannot be created: `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)`, or when a configuration update fails: `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig)` or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)`. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionConfigUpdated()() ` Called when a publish or subscribe discovery session configuration update request succeeds. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()() ` Called when a discovery session (publish or subscribe) terminates. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSubscribeStarted(android.net.wifi.aware.SubscribeDiscoverySession)(https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession session) ` Called when a subscribe operation is started successfully in response to a `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` operation. |

### 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*.

## Public constructors

### DiscoverySessionCallback

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

```
public DiscoverySessionCallback ()
```

<br />

<br />

## Public methods

### onBootstrappingFailed

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

```
public void onBootstrappingFailed (PeerHandle peerHandle)
```

Callback indicating that a Bootstrapping method negotiation failed.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The bootstrapping peer handle. This value cannot be `null`. <br /> |

### onBootstrappingSucceeded

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

```
public void onBootstrappingSucceeded (PeerHandle peerHandle, 
                int method, 
                byte[] message)
```

Callback indicating that a Bootstrapping method negotiation succeeded. The follow-up out-of-band bootstrapping can start.

This variant is similar to `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onBootstrappingSucceeded(android.net.wifi.aware.PeerHandle,%20int)`, but includes optional service specific information provided by the peer during the request.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The bootstrapping peer handle. This value cannot be `null`. <br /> |
| `method` | `int`: The bootstrapping method accepted by the peer. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_OPPORTUNISTIC` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_TAG` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_KEYPAD` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_KEYPAD` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_SCAN` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_READER` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_SERVICE_MANAGED` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_SKIPPED` |
| `message` | `byte`: An arbitrary byte array sent by the peer as part of its bootstrapping request `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiateBootstrappingRequest(android.net.wifi.aware.PeerHandle,%20int,%20byte[])`. It will be non-null only on publisher side when the peer sets a message in its bootstrapping request. It will always be null on subscriber side. <br /> |

### onBootstrappingSucceeded

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

```
public void onBootstrappingSucceeded (PeerHandle peerHandle, 
                int method)
```

Callback indicating that a Bootstrapping method negotiation succeeded. The follow-up out-of-band bootstrapping can start

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The bootstrapping peer handle. This value cannot be `null`. <br /> |
| `method` | `int`: The bootstrapping method accepted by the peer. Value is either `0` or a combination of the following: - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_OPPORTUNISTIC` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_DISPLAY` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_TAG` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PIN_CODE_KEYPAD` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_PASSPHRASE_KEYPAD` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_QR_SCAN` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_NFC_READER` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_SERVICE_MANAGED` - `https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig#PAIRING_BOOTSTRAPPING_SKIPPED` |

### onDataPathConnected

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

```
public void onDataPathConnected (PeerHandle peerHandle, 
                WifiAwareNetworkInfo info)
```

Callback indicating that a data path has been connected.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The peer's handle for the data path request. This value cannot be `null`. <br /> |
| `info` | `WifiAwareNetworkInfo`: The network information of the connected data path. This value cannot be `null`. <br /> |

### onDataPathDisconnected

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

```
public void onDataPathDisconnected (PeerHandle peerHandle)
```

Callback indicating that a data path has been disconnected. Could be triggered by either side calling `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#releaseDataPath(android.net.wifi.aware.PeerHandle)`.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The peer's handle for the data path request. This value cannot be `null`. <br /> |

### onDataPathRequestFailed

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

```
public void onDataPathRequestFailed (PeerHandle peerHandle, 
                int reason)
```

Callback indicating that a data path request has failed.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The peer's handle for the data path request. This value cannot be `null`. <br /> |
| `reason` | `int`: The reason for the data path connection failure. Value is one of the following: - `https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest#DATA_PATH_CONNECTION_FAILURE_REASON_NO_RESOURCE` - `https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest#DATA_PATH_CONNECTION_FAILURE_REASON_PEER_NOT_FOUND` - `https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest#DATA_PATH_CONNECTION_FAILURE_REASON_REJECT_BY_PEER` - `https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest#DATA_PATH_CONNECTION_FAILURE_REASON_TIME_OUT` - `https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest#DATA_PATH_CONNECTION_FAILURE_REASON_INTERNAL_FAILURE` |

### onDataPathRequestReceived

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

```
public void onDataPathRequestReceived (PeerHandle peerHandle)
```

Callback indicating that a data path request has been received. Caller should call `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#acceptDataPathRequest(android.net.wifi.aware.PeerHandle,%20android.net.wifi.aware.AwareDataPathRequest)` to set up the data path. Or call `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#rejectDataPathRequest(android.net.wifi.aware.PeerHandle)` to reject the request.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The peer's handle for the data path request. This value cannot be `null`. <br /> |

### onMessageReceived

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

```
public void onMessageReceived (PeerHandle peerHandle, 
                byte[] message)
```

Called when a message is received from a discovery session peer - in response to the peer's `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])`.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: An opaque handle to the peer matching our discovery operation. <br /> |
| `message` | `byte`: A byte array containing the message. <br /> |

### onMessageSendFailed

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

```
public void onMessageSendFailed (int messageId)
```

Called when message transmission initiated with `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])` fails. E.g. when no ACK is received from the peer.

Note that either this callback or `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onMessageSendSucceeded(int)` will be received - never both.

<br />

| Parameters ||
|---|---|
| `messageId` | `int`: The arbitrary message ID specified when sending the message. <br /> |

### onMessageSendSucceeded

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

```
public void onMessageSendSucceeded (int messageId)
```

Called in response to `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])` when a message is transmitted successfully - i.e. when it was received successfully by the peer (corresponds to an ACK being received).

Note that either this callback or `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onMessageSendFailed(int)` will be received - never both.

<br />

| Parameters ||
|---|---|
| `messageId` | `int`: The arbitrary message ID specified when sending the message. <br /> |

### onPairingSetupFailed

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

```
public void onPairingSetupFailed (PeerHandle peerHandle)
```

Callback indicating that a pairing setup process failed.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The pairing peer handle. This value cannot be `null`. <br /> |

### onPairingSetupRequestReceived

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

```
public void onPairingSetupRequestReceived (PeerHandle peerHandle, 
                int requestId)
```

Callback indicating that a pairing request is received from peer.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The peer's handle where the request is from. This value cannot be `null`. <br /> |
| `requestId` | `int`: The ID of the Aware pairing session <br /> |

### onPairingSetupSucceeded

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

```
public void onPairingSetupSucceeded (PeerHandle peerHandle, 
                String alias)
```

Callback indicating that a pairing setup process succeeded.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The pairing peer handle. This value cannot be `null`. <br /> |
| `alias` | `String`: This is the paired device alias set by the caller. `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` or `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` This value cannot be `null`. <br /> |

### onPairingVerificationFailed

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

```
public void onPairingVerificationFailed (PeerHandle peerHandle)
```

Callback indicating that a pairing verification process failed.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The pairing peer handle. This value cannot be `null`. <br /> |

### onPairingVerificationSucceed

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

```
public void onPairingVerificationSucceed (PeerHandle peerHandle, 
                String alias)
```

Callback indicating that a pairing verification process succeeded.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: The pairing peer handle. This value cannot be `null`. <br /> |
| `alias` | `String`: This is the paired device alias set by the caller. `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` or `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)` This value cannot be `null`. <br /> |

### onPublishStarted

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

```
public void onPublishStarted (PublishDiscoverySession session)
```

Called when a publish operation is started successfully in response to a `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` operation.

<br />

| Parameters ||
|---|---|
| `session` | `PublishDiscoverySession`: The `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession` used to control the discovery session. This value cannot be `null`. <br /> |

### onServiceDiscovered

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

```
public void onServiceDiscovered (PeerHandle peerHandle, 
                byte[] serviceSpecificInfo, 
                List<byte[]> matchFilter)
```

Called when a subscribe operation results in a service discovery.

Note that this method and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>,%20int)` may be called multiple times per service discovery.

Note: This method is superseded by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.ServiceDiscoveryInfo)` which returns more information. Note that both legacy and new callback will be triggered on discovery.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: An opaque handle to the peer matching our discovery operation. <br /> |
| `serviceSpecificInfo` | `byte`: The service specific information (arbitrary byte array) provided by the peer as part of its discovery configuration. <br /> |
| `matchFilter` | `List`: The filter which resulted in this service discovery. For `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED`, `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE` discovery sessions this is the publisher's match filter. For `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED`, `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE` discovery sessions this is the subscriber's match filter. <br /> |

### onServiceDiscovered

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

```
public void onServiceDiscovered (ServiceDiscoveryInfo info)
```

Called when a subscribe operation results in a service discovery.

Note: This method supersedes `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)` and provides additional information - including cipher suite type and security context of the peer. Both the legacy and the new callback will be triggered on discovery.

<br />

| Parameters ||
|---|---|
| `info` | `ServiceDiscoveryInfo`: A `https://developer.android.com/reference/android/net/wifi/aware/ServiceDiscoveryInfo` structure containing information on the discovery session and the discovered peer. This value cannot be `null`. <br /> |

### onServiceDiscoveredWithinRange

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

```
public void onServiceDiscoveredWithinRange (ServiceDiscoveryInfo info, 
                int distanceMm)
```

Called when a subscribe operation results in a service discovery. Called when a Subscribe service was configured with a range requirement `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setEgressDistanceMm(int)` and/or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setIngressDistanceMm(int)` and the Publish service was configured with `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setRangingEnabled(boolean)`.

If either Publisher or Subscriber does not enable Ranging, or if Ranging is temporarily disabled by the underlying device, service discovery proceeds without ranging and the `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)` is called.

Note: This method supersedes `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>,%20int)` and provides additional information - including cipher suite type and security context of the peer. Both the legacy and the new callback will be triggered on discovery.

<br />

| Parameters ||
|---|---|
| `info` | `ServiceDiscoveryInfo`: A `https://developer.android.com/reference/android/net/wifi/aware/ServiceDiscoveryInfo` which indicate service config of the descovery sessions. This value cannot be `null`. <br /> |
| `distanceMm` | `int`: The measured distance to the Publisher in mm. Note: the measured distance may be negative for very close devices. <br /> |

### onServiceDiscoveredWithinRange

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

```
public void onServiceDiscoveredWithinRange (PeerHandle peerHandle, 
                byte[] serviceSpecificInfo, 
                List<byte[]> matchFilter, 
                int distanceMm)
```

Called when a subscribe operation results in a service discovery. Called when a Subscribe service was configured with a range requirement `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setEgressDistanceMm(int)` and/or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setIngressDistanceMm(int)` and the Publish service was configured with `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setRangingEnabled(boolean)`.

If either Publisher or Subscriber does not enable Ranging, or if Ranging is temporarily disabled by the underlying device, service discovery proceeds without ranging and the `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)` is called.

Note that this method and `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)` may be called multiple times per service discovery.

Note: This method is superseded by `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.ServiceDiscoveryInfo,%20int)` which returns more information. Note that both legacy and new callback will be triggered on discovery.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: An opaque handle to the peer matching our discovery operation. <br /> |
| `serviceSpecificInfo` | `byte`: The service specific information (arbitrary byte array) provided by the peer as part of its discovery configuration. <br /> |
| `matchFilter` | `List`: The filter which resulted in this service discovery. For `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED`, `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig#SUBSCRIBE_TYPE_PASSIVE` discovery sessions this is the publisher's match filter. For `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED`, `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig#SUBSCRIBE_TYPE_ACTIVE` discovery sessions this is the subscriber's match filter. <br /> |
| `distanceMm` | `int`: The measured distance to the Publisher in mm. Note: the measured distance may be negative for very close devices. <br /> |

### onServiceLost

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

```
public void onServiceLost (PeerHandle peerHandle, 
                int reason)
```

Called when the discovered service is not available. All further operations on this discovery session will fail. If the service is available again, `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>)` or `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscoveredWithinRange(android.net.wifi.aware.PeerHandle,%20byte[],%20java.util.List<byte[]>,%20int)` will be called.

<br />

| Parameters ||
|---|---|
| `peerHandle` | `PeerHandle`: An opaque handle to the peer matching our discovery operation. This value cannot be `null`. <br /> |
| `reason` | `int`: Discovered service lost reason code. One of `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE`, `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN` Value is one of the following: - `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_UNKNOWN` - `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareManager#WIFI_AWARE_DISCOVERY_LOST_REASON_PEER_NOT_VISIBLE` |

### onSessionConfigFailed

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

```
public void onSessionConfigFailed ()
```

Called when a publish or subscribe discovery session cannot be created: `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)`, or when a configuration update fails: `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig)` or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)`.

For discovery session updates failure leaves the session running with its previous configuration - the discovery session is not terminated.

<br />

### onSessionConfigUpdated

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

```
public void onSessionConfigUpdated ()
```

Called when a publish or subscribe discovery session configuration update request succeeds. Called in response to `https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig)` or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)`.

<br />

### onSessionTerminated

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

```
public void onSessionTerminated ()
```

Called when a discovery session (publish or subscribe) terminates. Termination may be due to user-request (either directly through `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#close()` or application-specified expiration, e.g. `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setTtlSec(int)` or `https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setTtlSec(int)`).

<br />

### onSubscribeStarted

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

```
public void onSubscribeStarted (SubscribeDiscoverySession session)
```

Called when a subscribe operation is started successfully in response to a `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` operation.

<br />

| Parameters ||
|---|---|
| `session` | `SubscribeDiscoverySession`: The `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession` used to control the discovery session. This value cannot be `null`. <br /> |