다음을 통해 공유


WifiAwareManager Class

Definition

This class provides the primary API for managing Wi-Fi Aware operations: discovery and peer-to-peer data connections.

[Android.Runtime.Register("android/net/wifi/aware/WifiAwareManager", ApiSince=26, DoNotGenerateAcw=true)]
public class WifiAwareManager : Java.Lang.Object
[<Android.Runtime.Register("android/net/wifi/aware/WifiAwareManager", ApiSince=26, DoNotGenerateAcw=true)>]
type WifiAwareManager = class
    inherit Object
Inheritance
WifiAwareManager
Attributes

Remarks

This class provides the primary API for managing Wi-Fi Aware operations: discovery and peer-to-peer data connections.

The class provides access to: <ul> <li>Initialize a Aware cluster (peer-to-peer synchronization). Refer to #attach(AttachCallback, Handler). <li>Create discovery sessions (publish or subscribe sessions). Refer to WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler) and WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, Handler). <li>Create a Aware network specifier to be used with ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback) to set-up a Aware connection with a peer. Refer to WifiAwareNetworkSpecifier.Builder. </ul>

Aware may not be usable when Wi-Fi is disabled (and other conditions). To validate that the functionality is available use the #isAvailable() function. To track changes in Aware usability register for the #ACTION_WIFI_AWARE_STATE_CHANGED broadcast. Note that this broadcast is not sticky - you should register for it and then check the above API to avoid a race condition.

An application must use #attach(AttachCallback, Handler) to initialize a Aware cluster - before making any other Aware operation. Aware cluster membership is a device-wide operation - the API guarantees that the device is in a cluster or joins a Aware cluster (or starts one if none can be found). Information about attach success (or failure) are returned in callbacks of AttachCallback. Proceed with Aware discovery or connection setup only after receiving confirmation that Aware attach succeeded - AttachCallback#onAttached(WifiAwareSession). When an application is finished using Aware it <b>must</b> use the WifiAwareSession#close() API to indicate to the Aware service that the device may detach from the Aware cluster. The device will actually disable Aware once the last application detaches.

Once a Aware attach is confirmed use the WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback, Handler) or WifiAwareSession#subscribe(SubscribeConfig, DiscoverySessionCallback, Handler) to create publish or subscribe Aware discovery sessions. Events are called on the provided callback object DiscoverySessionCallback. Specifically, the DiscoverySessionCallback#onPublishStarted(PublishDiscoverySession) and DiscoverySessionCallback#onSubscribeStarted( SubscribeDiscoverySession) return PublishDiscoverySession and SubscribeDiscoverySession objects respectively on which additional session operations can be performed, e.g. updating the session PublishDiscoverySession#updatePublish(PublishConfig) and SubscribeDiscoverySession#updateSubscribe(SubscribeConfig). Sessions can also be used to send messages using the DiscoverySession#sendMessage(PeerHandle, int, byte[]) APIs. When an application is finished with a discovery session it <b>must</b> terminate it using the DiscoverySession#close() API.

Creating connections between Aware devices is managed by the standard ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback). The NetworkRequest object should be constructed with: <ul> <li>NetworkRequest.Builder#addTransportType(int) of android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE. <li>NetworkRequest.Builder#setNetworkSpecifier(String) using WifiAwareNetworkSpecifier.Builder. </ul>

Java documentation for android.net.wifi.aware.WifiAwareManager.

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.

Constructors

WifiAwareManager(IntPtr, JniHandleOwnership)

Fields

ActionWifiAwareResourceChanged

Intent broadcast sent whenever Wi-Fi Aware resource availability has changed.

ActionWifiAwareStateChanged

Broadcast intent action to indicate that the state of Wi-Fi Aware availability has changed and all active Aware sessions are no longer usable.

ExtraAwareResources

Sent as a part of #ACTION_WIFI_AWARE_RESOURCE_CHANGED that contains an instance of AwareResources representing the current Wi-Fi Aware resources.

WifiAwareDiscoveryLostReasonPeerNotVisible
Obsolete.

Reason code provided in DiscoverySessionCallback#onServiceLost(PeerHandle, int) indicating that the service advertised by the peer is no longer visible.

WifiAwareDiscoveryLostReasonUnknown
Obsolete.

Reason code provided in DiscoverySessionCallback#onServiceLost(PeerHandle, int) indicating that the service was lost for unknown reason.

Properties

AvailableAwareResources

Return the available resources of the Wi-Fi aware service: a set of parameters which specify limitations on service usage, e.

Characteristics

Returns the characteristics of the Wi-Fi Aware interface: a set of parameters which specify limitations on configurations, e.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsAvailable

Returns the current status of Aware API: whether or not Aware is available.

IsDeviceAttached

Return the current status of the Aware service: whether or not the device is already attached to an Aware cluster.

IsInstantCommunicationModeEnabled

Return the current status of the Wifi Aware instant communication mode.

IsSetChannelOnDataPathSupported

Return the device support for setting a channel requirement in a data-path request.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass
ThresholdType

Methods

Attach(AttachCallback, Handler)

Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers.

Attach(AttachCallback, IdentityChangedListener, Handler)

Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or create connections to peers.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetPairedDevices(IExecutor, IConsumer)

Get all the paired devices configured by the calling app.

IsOpportunisticModeEnabled(IExecutor, IConsumer)

Indicate whether all Wi-Fi Aware sessions created by the calling app are opportunistic as defined and configured by #setOpportunisticModeEnabled(boolean)

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
RemovePairedDevice(String)

Remove the target paired device setup by the caller by DiscoverySession#initiatePairingRequest(PeerHandle, String, int, String) and DiscoverySession#acceptPairingRequest(int, PeerHandle, String, int, String)

ResetPairedDevices()

Reset all paired devices setup by the caller by DiscoverySession#initiatePairingRequest(PeerHandle, String, int, String) and DiscoverySession#acceptPairingRequest(int, PeerHandle, String, int, String)

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetOpportunisticModeEnabled(Boolean)

Set all Wi-Fi Aware sessions created by the calling app to be opportunistic.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to