BluetoothLeScanner.StartScan 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| StartScan(ScanCallback) |
用預設參數且不設過濾器開始藍牙 LE 掃描。 |
| StartScan(IList<ScanFilter>, ScanSettings, PendingIntent) |
開始用 |
| StartScan(IList<ScanFilter>, ScanSettings, ScanCallback) |
開始藍牙 LE 掃描。 |
StartScan(ScanCallback)
用預設參數且不設過濾器開始藍牙 LE 掃描。
[Android.Runtime.Register("startScan", "(Landroid/bluetooth/le/ScanCallback;)V", "")]
public void StartScan(Android.Bluetooth.LE.ScanCallback callback);
[<Android.Runtime.Register("startScan", "(Landroid/bluetooth/le/ScanCallback;)V", "")>]
member this.StartScan : Android.Bluetooth.LE.ScanCallback -> unit
參數
- callback
- ScanCallback
回撥過去用來提供掃描結果。
- 屬性
例外狀況
若為 callback 空。
備註
用預設參數且不設過濾器開始藍牙 LE 掃描。 掃描結果將透過 傳送。callback 對於未過濾的掃描,掃描會關閉螢幕以節省電力。 當螢幕再次亮起時,掃描會繼續進行。 為避免此情況,請使用 #startScan(List, ScanSettings, ScanCallback) 所欲 ScanFilter的 。
應用程式必須取得 android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION 授權才能取得結果。 針對 Android Q 或更新版本的應用程式必須取得 android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION 授權才能獲得結果。
Java 文件 android.bluetooth.le.BluetoothLeScanner.startScan(android.bluetooth.le.ScanCallback)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
StartScan(IList<ScanFilter>, ScanSettings, PendingIntent)
開始用 PendingIntent.
[Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/app/PendingIntent;)I", "", ApiSince=26)]
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)>]
member this.StartScan : System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter> * Android.Bluetooth.LE.ScanSettings * Android.App.PendingIntent -> int
參數
- filters
- IList<ScanFilter>
可選的掃描過濾器清單,用於尋找精確的BLE裝置。
- settings
- ScanSettings
掃描可選設定。
- callbackIntent
- PendingIntent
交付結果的待定意圖。
傳回
若掃描請求無法傳送,則回傳 0 以成功或錯誤代碼 ScanCallback 表示。
- 屬性
備註
開始用 PendingIntent. 掃描結果將透過 PendingIntent 提供。 如果你的程序並非一直運行,請使用此掃描方法,且當掃描結果顯示時應啟動。
應用程式必須取得 android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION 授權才能取得結果。 針對 Android Q 或更新版本的應用程式必須取得 android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION 授權才能獲得結果。
當 PendingIntent 交付時,傳達給接收者或活動的 Intent 會包含一個或多個額外內容 #EXTRA_CALLBACK_TYPE, #EXTRA_ERROR_CODE 並 #EXTRA_LIST_SCAN_RESULT 指示掃描結果。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
適用於
StartScan(IList<ScanFilter>, ScanSettings, ScanCallback)
開始藍牙 LE 掃描。
[Android.Runtime.Register("startScan", "(Ljava/util/List;Landroid/bluetooth/le/ScanSettings;Landroid/bluetooth/le/ScanCallback;)V", "")]
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", "")>]
member this.StartScan : System.Collections.Generic.IList<Android.Bluetooth.LE.ScanFilter> * Android.Bluetooth.LE.ScanSettings * Android.Bluetooth.LE.ScanCallback -> unit
參數
- filters
- IList<ScanFilter>
ScanFilter用來尋找精確的BLE裝置。
- settings
- ScanSettings
掃描設定。
- callback
- ScanCallback
回撥過去用來提供掃描結果。
- 屬性
備註
開始藍牙 LE 掃描。 掃描結果將透過 傳送。callback 對於未過濾的掃描,掃描會關閉螢幕以節省電力。 當螢幕再次亮起時,掃描會繼續進行。 為避免這種情況,請使用正確的 ScanFilter進行過濾掃描。
應用程式必須取得 android.Manifest.permission#ACCESS_COARSE_LOCATION ACCESS_COARSE_LOCATION 授權才能取得結果。 針對 Android Q 或更新版本的應用程式必須取得 android.Manifest.permission#ACCESS_FINE_LOCATION ACCESS_FINE_LOCATION 授權才能獲得結果。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。