Share via


WifiAwareSession.Subscribe Method

Definition

Issue a request to the Aware service to create a new Aware subscribe discovery session, using the specified subscribeConfig configuration.

[Android.Runtime.Register("subscribe", "(Landroid/net/wifi/aware/SubscribeConfig;Landroid/net/wifi/aware/DiscoverySessionCallback;Landroid/os/Handler;)V", "GetSubscribe_Landroid_net_wifi_aware_SubscribeConfig_Landroid_net_wifi_aware_DiscoverySessionCallback_Landroid_os_Handler_Handler", ApiSince=26)]
public virtual void Subscribe (Android.Net.Wifi.Aware.SubscribeConfig subscribeConfig, Android.Net.Wifi.Aware.DiscoverySessionCallback callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("subscribe", "(Landroid/net/wifi/aware/SubscribeConfig;Landroid/net/wifi/aware/DiscoverySessionCallback;Landroid/os/Handler;)V", "GetSubscribe_Landroid_net_wifi_aware_SubscribeConfig_Landroid_net_wifi_aware_DiscoverySessionCallback_Landroid_os_Handler_Handler", ApiSince=26)>]
abstract member Subscribe : Android.Net.Wifi.Aware.SubscribeConfig * Android.Net.Wifi.Aware.DiscoverySessionCallback * Android.OS.Handler -> unit
override this.Subscribe : Android.Net.Wifi.Aware.SubscribeConfig * Android.Net.Wifi.Aware.DiscoverySessionCallback * Android.OS.Handler -> unit

Parameters

subscribeConfig
SubscribeConfig

The SubscribeConfig specifying the configuration of the requested subscribe session.

callback
DiscoverySessionCallback

A DiscoverySessionCallback derived object to be used for session event callbacks.

handler
Handler

The Handler on whose thread to execute the callbacks of the callback object. If a null is provided then the application's main thread will be used.

Attributes

Remarks

Issue a request to the Aware service to create a new Aware subscribe discovery session, using the specified subscribeConfig configuration. The results of the subscribe operation are routed to the callbacks of DiscoverySessionCallback: <ul> <li> DiscoverySessionCallback#onSubscribeStarted( SubscribeDiscoverySession) is called when the subscribe session is created and provides a handle to the session. Further operations on the subscribe session can be executed on that object. <li>DiscoverySessionCallback#onSessionConfigFailed() is called if the subscribe operation failed. </ul>

Other results of the subscribe session operations will also be routed to callbacks on the callback object. The resulting subscribe session can be modified using SubscribeDiscoverySession#updateSubscribe(SubscribeConfig).

The total count of currently available Wi-Fi Aware subscribe sessions is limited and is available via the AwareResources#getAvailableSubscribeSessionsCount() method.

An application must use the DiscoverySession#close() to terminate the subscribe discovery session once it isn't needed. This will free resources as well terminate any on-air transmissions.

If targeting android.os.Build.VERSION_CODES#TIRAMISU or later, the application must have android.Manifest.permission#NEARBY_WIFI_DEVICES with android:usesPermissionFlags="neverForLocation". If the application does not declare android:usesPermissionFlags="neverForLocation", then it must also have android.Manifest.permission#ACCESS_FINE_LOCATION.

If targeting an earlier release than android.os.Build.VERSION_CODES#TIRAMISU, the application must have android.Manifest.permission#ACCESS_FINE_LOCATION.

Java documentation for android.net.wifi.aware.WifiAwareSession.subscribe(android.net.wifi.aware.SubscribeConfig, android.net.wifi.aware.DiscoverySessionCallback, android.os.Handler).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to