Class BleScan
Live handle of a running BLE scan returned by
BluetoothLE.startScan(ScanSettings, ScanListener). Any number of
scans may run concurrently -- each handle only sees advertisements
passing its own filters.
As an AsyncResource<Boolean> the handle resolves when the scan
ends: with true after a normal stop(), or with a
BluetoothException when the OS aborted the
scan. cancel() is equivalent to stop().
-
Nested Class Summary
Nested classes/interfaces inherited from class AsyncResource
AsyncResource.AsyncExecutionException, AsyncResource.CancellationException -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBleScan()Created byBluetoothLE; application code receives instances fromstartScan. -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) Equivalent tostop().booleanisActive()truewhile the scan is running.protected voidonStop()Hook forBluetoothLEto unregister the handle and stop the platform scan when it was the last one; invoked exactly once fromstop().voidstop()Stops this scan.Methods inherited from class AsyncResource
addListener, all, all, asPromise, await, await, await, complete, error, except, except, get, get, get, isCancelled, isCancelled, isDone, isReady, onResult, ready, ready, waitForMethods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Constructor Details
-
BleScan
protected BleScan()Created byBluetoothLE; application code receives instances fromstartScan.
-
-
Method Details
-
stop
public void stop()Stops this scan. The handle resolves withtrue; the underlying platform scan keeps running while other handles remain active. Callingstop()on an already ended scan is a no-op. -
isActive
public boolean isActive()truewhile the scan is running. -
cancel
public boolean cancel(boolean mayInterruptIfRunning) Equivalent tostop().- Overrides:
cancelin classAsyncResource<Boolean>
-
onStop
protected void onStop()Hook forBluetoothLEto unregister the handle and stop the platform scan when it was the last one; invoked exactly once fromstop().
-