Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
    
    SubscribeDiscoverySession
    open class SubscribeDiscoverySession : DiscoverySession
    
    A class representing a Aware subscribe session. Created when WifiAwareSession.subscribe(SubscribeConfig, is called and a discovery session is created and returned in DiscoverySessionCallback.onSubscribeStarted(SubscribeDiscoverySession). See baseline functionality of all discovery sessions in DiscoverySession. This object allows updating an existing/running subscribe discovery session using updateSubscribe(android.net.wifi.aware.SubscribeConfig).
    Summary
    
      
        
          | Public methods | 
        
          | open Unit | Re-configure the currently active subscribe session. | 
      
    
    
      
        
          | Inherited functions | 
        
          | From class DiscoverySession
                
                  
                    | Unit | acceptPairingRequest(requestId: Int, peerHandle: PeerHandle, peerDeviceAlias: String, cipherSuite: Int, password: String?)
                         Accept and respond to a Wi-Fi Aware Pairing setup request received from peer. This is the response to the DiscoverySessionCallback.onPairingSetupRequestReceived(PeerHandle, int)When the Aware Pairing setup is finished, both sides will receiveDiscoverySessionCallback.onPairingSetupSucceeded(PeerHandle, String) |  
                    | Unit | 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). The session may not be used for any additional operations after its destruction.   This operation must be done on a session which is no longer needed. Otherwise system resources will continue to be utilized until the application exits. The only exception is a session for which we received a termination callback, DiscoverySessionCallback.onSessionTerminated(). |  
                    | NetworkSpecifier! | createNetworkSpecifierOpen(peerHandle: PeerHandle)
                         Create a android.net.NetworkRequest.Builder#setNetworkSpecifier(NetworkSpecifier)for an unencrypted WiFi Aware connection (link) to the specified peer. Theandroid.net.NetworkRequest.Builder#addTransportType(int)should be set toandroid.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE.  This method should be used when setting up a connection with a peer discovered through Aware discovery or communication (in such scenarios the MAC address of the peer is shielded by an opaque peer ID handle). If an Aware connection is needed to a peer discovered using other OOB (out-of-band) mechanism then use the alternative WifiAwareSession.createNetworkSpecifierOpen(int, byte[])method - which uses the peer's MAC address.  Note: per the Wi-Fi Aware specification the roles are fixed - a Subscriber is an INITIATOR and a Publisher is a RESPONDER.   To set up an encrypted link use the createNetworkSpecifierPassphrase(android.net.wifi.aware.PeerHandle,java.lang.String)API. |  
                    | NetworkSpecifier! | createNetworkSpecifierPassphrase(peerHandle: PeerHandle, passphrase: String)
                         Create a android.net.NetworkRequest.Builder#setNetworkSpecifier(NetworkSpecifier)for an encrypted WiFi Aware connection (link) to the specified peer. Theandroid.net.NetworkRequest.Builder#addTransportType(int)should be set toandroid.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE.  This method should be used when setting up a connection with a peer discovered through Aware discovery or communication (in such scenarios the MAC address of the peer is shielded by an opaque peer ID handle). If an Aware connection is needed to a peer discovered using other OOB (out-of-band) mechanism then use the alternative WifiAwareSession.createNetworkSpecifierPassphrase(int, byte[], String)method - which uses the peer's MAC address.  Note: per the Wi-Fi Aware specification the roles are fixed - a Subscriber is an INITIATOR and a Publisher is a RESPONDER. |  
                    | Unit | initiateBootstrappingRequest(peerHandle: PeerHandle, method: Int)
                         Initiate a Wi-Fi Aware bootstrapping setup request to create a pairing with the target peer. The Aware bootstrapping request should be done in the context of a discovery session - after a publish/subscribe DiscoverySessionCallback.onServiceDiscovered(ServiceDiscoveryInfo)event is received. The peer will check if the method can be fulfilled byAwarePairingConfig.Builder.setBootstrappingMethods(int)When the Aware Bootstrapping setup finished, both side will receiveDiscoverySessionCallback.onBootstrappingSucceeded(PeerHandle, int) |  
                    | Unit | initiatePairingRequest(peerHandle: PeerHandle, peerDeviceAlias: String, cipherSuite: Int, password: String?)
                         Initiate a Wi-Fi Aware Pairing setup request to create a pairing with the target peer. The Aware pairing request should be done in the context of a discovery session - after a publish/subscribe DiscoverySessionCallback.onServiceDiscovered(ServiceDiscoveryInfo)event is received. The peer will get a callback indicating a message was received usingDiscoverySessionCallback.onPairingSetupRequestReceived(PeerHandle, int). When the Aware Pairing setup is finished, both sides will receiveDiscoverySessionCallback.onPairingSetupSucceeded(PeerHandle, String) |  
                    | Unit | rejectPairingRequest(requestId: Int, peerHandle: PeerHandle)
                         Reject a Wi-Fi Aware Pairing setup request received from peer. This is the response to the DiscoverySessionCallback.onPairingSetupRequestReceived(PeerHandle, int) |  
                    | Unit | sendMessage(peerHandle: PeerHandle, messageId: Int, message: ByteArray?)
                         Sends a message to the specified destination. Aware messages are transmitted in the context of a discovery session - executed subsequent to a publish/subscribe DiscoverySessionCallback.onServiceDiscovered(PeerHandle,event.  Aware messages are not guaranteed delivery. Callbacks on DiscoverySessionCallbackindicate message was transmitted successfully,DiscoverySessionCallback.onMessageSendSucceeded(int), or transmission failed (possibly after several retries) -DiscoverySessionCallback.onMessageSendFailed(int).  The peer will get a callback indicating a message was received using DiscoverySessionCallback.onMessageReceived(PeerHandle,. |  | 
      
    
    Public methods
    
  
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [null,null,["Last updated 2025-02-10 UTC."],[],[]]