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

# SubscribeDiscoverySession

*** ** * ** ***

` public class SubscribeDiscoverySession `   
` ` ` extends https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession ` ` `

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

<br />

*** ** * ** ***

A class representing a Aware subscribe session. Created when `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler)` is called and a discovery session is created and returned in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSubscribeStarted(android.net.wifi.aware.SubscribeDiscoverySession)`. See baseline functionality of all discovery sessions in `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession`. This object allows updating an existing/running subscribe discovery session using `https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)`.

## Summary

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#initiateDataPathRequest(android.net.wifi.aware.PeerHandle,%20android.net.wifi.aware.AwareDataPathRequest)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/android/net/wifi/aware/AwareDataPathRequest request) ` Initiate a Wi-Fi Aware data path request to create a connection with the target peer. |
| ` void` | ` https://developer.android.com/reference/android/net/wifi/aware/SubscribeDiscoverySession#updateSubscribe(android.net.wifi.aware.SubscribeConfig)(https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig subscribeConfig) ` Re-configure the currently active subscribe session. |

### Inherited methods

From class ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession ` ` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#acceptPairingRequest(int,%20android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)(int requestId, https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/java/lang/String peerDeviceAlias, int cipherSuite, https://developer.android.com/reference/java/lang/String password) `

Accept and respond to a Wi-Fi Aware Pairing setup request received from peer.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#close()() `

Destroy the publish or subscribe session - free any resources, and stop transmitting packets on-air (for an active session) or listening for matches (for a passive session).
` https://developer.android.com/reference/android/net/NetworkSpecifier` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#createNetworkSpecifierOpen(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) `

*This method was deprecated in API level 29. Use the replacement `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder`.*
` https://developer.android.com/reference/android/net/NetworkSpecifier` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#createNetworkSpecifierPassphrase(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 passphrase) `

*This method was deprecated in API level 29. Use the replacement `https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder`.*
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiateBootstrappingRequest(android.net.wifi.aware.PeerHandle,%20int,%20byte[])(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int method, byte[] message) `

Defined as per Wi-Fi Aware specifications version 4.0 Section 7.6.4.1.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiateBootstrappingRequest(android.net.wifi.aware.PeerHandle,%20int)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int method) `

Defined as per Wi-Fi Aware specifications version 4.0 Section 7.6.4.1.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, https://developer.android.com/reference/java/lang/String peerDeviceAlias, int cipherSuite, https://developer.android.com/reference/java/lang/String password) `

Initiate a Wi-Fi Aware Pairing setup request to create a pairing with the target peer.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#rejectPairingRequest(int,%20android.net.wifi.aware.PeerHandle)(int requestId, https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) `

Reject a Wi-Fi Aware Pairing setup request received from peer.
` boolean` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#releaseDataPath(android.net.wifi.aware.PeerHandle)(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle) `

Release the Aware data path to the specified peer.
` void` ` https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[])(https://developer.android.com/reference/android/net/wifi/aware/PeerHandle peerHandle, int messageId, byte[] message) `

Sends a message to the specified destination.
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*.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Public methods

### initiateDataPathRequest

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

```
public boolean initiateDataPathRequest (PeerHandle peerHandle, 
                AwareDataPathRequest request)
```

Initiate a Wi-Fi Aware data path request to create a connection with the target peer. The Aware data path request should be done in the context of a discovery session - after a `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onServiceDiscovered(android.net.wifi.aware.ServiceDiscoveryInfo)` event is received. When the Aware data path setup succeeds, both side will receive `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathConnected(android.net.wifi.aware.PeerHandle,%20android.net.wifi.aware.WifiAwareNetworkInfo)`. Otherwise `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onDataPathRequestFailed(android.net.wifi.aware.PeerHandle,%20int)` will be called.

<br />

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

| Returns ||
|---|---|
| `boolean` | true if framework starts the data path setup successfully, false otherwise. <br /> |

### updateSubscribe

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

```
public void updateSubscribe (SubscribeConfig subscribeConfig)
```

Re-configure the currently active subscribe session. The `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback` is not replaced - the same listener used at creation is still used. The results of the configuration are returned using `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback`:

- `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionConfigUpdated()`: configuration update succeeded.
- `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionConfigFailed()`: configuration update failed. The subscribe discovery session is still running using its previous configuration (i.e. update failure does not terminate the session).

<br />

<br />

| Parameters ||
|---|---|
| `subscribeConfig` | `SubscribeConfig`: The new discovery subscribe session configuration (`https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig`). This value cannot be `null`. <br /> |