Share via


WifiAwareSession.Publish Method

Definition

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

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

Parameters

publishConfig
PublishConfig

The PublishConfig specifying the configuration of the requested publish 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 publish discovery session, using the specified publishConfig configuration. The results of the publish operation are routed to the callbacks of DiscoverySessionCallback: <ul> <li> DiscoverySessionCallback#onPublishStarted( PublishDiscoverySession) is called when the publish session is created and provides a handle to the session. Further operations on the publish session can be executed on that object. <li>DiscoverySessionCallback#onSessionConfigFailed() is called if the publish operation failed. </ul>

Other results of the publish session operations will also be routed to callbacks on the callback object. The resulting publish session can be modified using PublishDiscoverySession#updatePublish(PublishConfig).

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

An application must use the DiscoverySession#close() to terminate the publish 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.publish(android.net.wifi.aware.PublishConfig, 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