BluetoothLeScanner.StartScan Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
StartScan(ScanCallback) |
Start Bluetooth LE scan with default parameters and no filters. |
StartScan(IList<ScanFilter>, ScanSettings, PendingIntent) |
Start Bluetooth LE scan using a |
StartScan(IList<ScanFilter>, ScanSettings, ScanCallback) |
Start Bluetooth LE scan. |
StartScan(ScanCallback)
Start Bluetooth LE scan with default parameters and no filters.
[Android.Runtime.Register("startScan", "(Landroid/bluetooth/le/ScanCallback;)V", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")]
public void StartScan (Android.Bluetooth.LE.ScanCallback? callback);
[<Android.Runtime.Register("startScan", "(Landroid/bluetooth/le/ScanCallback;)V", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")>]
member this.StartScan : Android.Bluetooth.LE.ScanCallback -> unit
Parameters
- callback
- ScanCallback
Callback used to deliver scan results.
- Attributes
Exceptions
If callback
is null.
Remarks
Start Bluetooth LE scan with default parameters and no filters. The scan results will be delivered through callback
. For unfiltered scans, scanning is stopped on screen off to save power. Scanning is resumed when screen is turned on again. To avoid this, use #startScan(List, ScanSettings, ScanCallback)
with desired ScanFilter
.
An app must have android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION
permission in order to get results. An App targeting Android Q or later must have android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION
permission in order to get results.
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
StartScan(IList<ScanFilter>, ScanSettings, PendingIntent)
Start Bluetooth LE scan using a PendingIntent
.
[Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/app/PendingIntent;)I", "", ApiSince=26)]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")]
public int StartScan (System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter>? filters, Android.Bluetooth.LE.ScanSettings? settings, Android.App.PendingIntent callbackIntent);
[<Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/app/PendingIntent;)I", "", ApiSince=26)>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")>]
member this.StartScan : System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter> * Android.Bluetooth.LE.ScanSettings * Android.App.PendingIntent -> int
Parameters
- filters
- IList<ScanFilter>
Optional list of ScanFilters for finding exact BLE devices.
- settings
- ScanSettings
Optional settings for the scan.
- callbackIntent
- PendingIntent
The PendingIntent to deliver the result to.
Returns
Returns 0 for success or an error code from ScanCallback
if the scan request
could not be sent.
- Attributes
Remarks
Start Bluetooth LE scan using a PendingIntent
. The scan results will be delivered via the PendingIntent. Use this method of scanning if your process is not always running and it should be started when scan results are available.
An app must have android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION
permission in order to get results. An App targeting Android Q or later must have android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION
permission in order to get results.
When the PendingIntent is delivered, the Intent passed to the receiver or activity will contain one or more of the extras #EXTRA_CALLBACK_TYPE
, #EXTRA_ERROR_CODE
and #EXTRA_LIST_SCAN_RESULT
to indicate the result of the scan.
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
StartScan(IList<ScanFilter>, ScanSettings, ScanCallback)
Start Bluetooth LE scan.
[Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/bluetooth/le/ScanCallback;)V", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")]
public void StartScan (System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter>? filters, Android.Bluetooth.LE.ScanSettings? settings, Android.Bluetooth.LE.ScanCallback? callback);
[<Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/bluetooth/le/ScanCallback;)V", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_SCAN")>]
member this.StartScan : System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter> * Android.Bluetooth.LE.ScanSettings * Android.Bluetooth.LE.ScanCallback -> unit
Parameters
- filters
- IList<ScanFilter>
ScanFilter
s for finding exact BLE devices.
- settings
- ScanSettings
Settings for the scan.
- callback
- ScanCallback
Callback used to deliver scan results.
- Attributes
Remarks
Start Bluetooth LE scan. The scan results will be delivered through callback
. For unfiltered scans, scanning is stopped on screen off to save power. Scanning is resumed when screen is turned on again. To avoid this, do filtered scanning by using proper ScanFilter
.
An app must have android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION
permission in order to get results. An App targeting Android Q or later must have android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION
permission in order to get results.
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.