# PublishDiscoverySession

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/PublishDiscoverySession#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#inhmethods)  

# PublishDiscoverySession

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishDiscoverySession "View this page in Kotlin")\|Java

`
public


class
PublishDiscoverySession
`  
`


``

extends `[DiscoverySession](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.PublishDiscoverySession |

<br />

*** ** * ** ***

A class representing a Aware publish session. Created when[WifiAwareSession.publish(PublishConfig, DiscoverySessionCallback,
android.os.Handler)](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler))is called and a discovery session is created and returned in[DiscoverySessionCallback.onPublishStarted(PublishDiscoverySession)](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onPublishStarted(android.net.wifi.aware.PublishDiscoverySession)). See baseline functionality of all discovery sessions in[DiscoverySession](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession). This object allows updating an existing/running publish discovery session using[updatePublish(android.net.wifi.aware.PublishConfig)](https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig)).

## Summary

|                                                                                                                                                              ### Public methods                                                                                                                                                              ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[updatePublish](https://developer.android.com/reference/android/net/wifi/aware/PublishDiscoverySession#updatePublish(android.net.wifi.aware.PublishConfig))`(`[PublishConfig](https://developer.android.com/reference/android/net/wifi/aware/PublishConfig)` publishConfig) ` Re-configure the currently active publish session. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.net.wifi.aware.DiscoverySession](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession)` ` |---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                                                     | ` `[acceptPairingRequest](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, `[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle, `[String](https://developer.android.com/reference/java/lang/String)` peerDeviceAlias, int cipherSuite, `[String](https://developer.android.com/reference/java/lang/String)` password) ` Accept and respond to a Wi-Fi Aware Pairing setup request received from peer. | | ` void`                                                                                     | ` `[close](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).                                                                                                                                                                                                                                                                                                                               | | ` `[NetworkSpecifier](https://developer.android.com/reference/android/net/NetworkSpecifier) | ` `[createNetworkSpecifierOpen](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#createNetworkSpecifierOpen(android.net.wifi.aware.PeerHandle))`(`[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle) ` *This method was deprecated in API level 29. Use the replacement[WifiAwareNetworkSpecifier.Builder](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder).*                                                                                                                      | | ` `[NetworkSpecifier](https://developer.android.com/reference/android/net/NetworkSpecifier) | ` `[createNetworkSpecifierPassphrase](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#createNetworkSpecifierPassphrase(android.net.wifi.aware.PeerHandle,%20java.lang.String))`(`[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle, `[String](https://developer.android.com/reference/java/lang/String)` passphrase) ` *This method was deprecated in API level 29. Use the replacement[WifiAwareNetworkSpecifier.Builder](https://developer.android.com/reference/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder).*     | | ` void`                                                                                     | ` `[initiateBootstrappingRequest](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiateBootstrappingRequest(android.net.wifi.aware.PeerHandle,%20int))`(`[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle, int method) ` Initiate a Wi-Fi Aware bootstrapping setup request to create a pairing with the target peer.                                                                                                                                                                                                          | | ` void`                                                                                     | ` `[initiatePairingRequest](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#initiatePairingRequest(android.net.wifi.aware.PeerHandle,%20java.lang.String,%20int,%20java.lang.String))`(`[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle, `[String](https://developer.android.com/reference/java/lang/String)` peerDeviceAlias, int cipherSuite, `[String](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`                                                                                     | ` `[rejectPairingRequest](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#rejectPairingRequest(int,%20android.net.wifi.aware.PeerHandle))`(int requestId, `[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle) ` Reject a Wi-Fi Aware Pairing setup request received from peer.                                                                                                                                                                                                                                                     | | ` void`                                                                                     | ` `[sendMessage](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySession#sendMessage(android.net.wifi.aware.PeerHandle,%20int,%20byte[]))`(`[PeerHandle](https://developer.android.com/reference/android/net/wifi/aware/PeerHandle)` peerHandle, int messageId, byte[] message) ` Sends a message to the specified destination.                                                                                                                                                                                                                                                              | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||

## Public methods

### updatePublish

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

```
public void updatePublish (PublishConfig publishConfig)
```

Re-configure the currently active publish session. The[DiscoverySessionCallback](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[DiscoverySessionCallback](https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback):

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

<br />

<br />

|                                                                                                      Parameters                                                                                                       ||
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `publishConfig` | `PublishConfig`: The new discovery publish session configuration ([PublishConfig](https://developer.android.com/reference/android/net/wifi/aware/PublishConfig)). This value cannot be`null`. <br /> |