Freigeben über


WifiManager.StartScan Method

Definition

Request a scan for access points.

[Android.Runtime.Register("startScan", "()Z", "GetStartScanHandler")]
public virtual bool StartScan ();
[<Android.Runtime.Register("startScan", "()Z", "GetStartScanHandler")>]
abstract member StartScan : unit -> bool
override this.StartScan : unit -> bool

Returns

true if the operation succeeded, i.e., the scan was initiated.

Attributes

Remarks

Request a scan for access points. Returns immediately. The availability of the results is made known later by means of an asynchronous event sent on completion of the scan.

To initiate a Wi-Fi scan, declare the android.Manifest.permission#CHANGE_WIFI_STATE permission in the manifest, and perform these steps:

<ol style="1"> <li>Invoke the following method: ((WifiManager) getSystemService(WIFI_SERVICE)).startScan()</li> <li> Register a BroadcastReceiver to listen to SCAN_RESULTS_AVAILABLE_ACTION.</li> <li>When a broadcast is received, call: ((WifiManager) getSystemService(WIFI_SERVICE)).getScanResults()</li> </ol>

This member is deprecated. The ability for apps to trigger scan requests will be removed in a future release.

Java documentation for android.net.wifi.WifiManager.startScan().

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