# Class BleScan

java.lang.Object
java.util.Observable
com.codename1.util.AsyncResource<Boolean>
com.codename1.bluetooth.le.BleScan

public class BleScan extends AsyncResource<Boolean>

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

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `BleScan()`
  Created by `BluetoothLE`; application code receives instances from `startScan`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `cancel(boolean mayInterruptIfRunning)`
  Equivalent to `stop()`.
  `boolean`
  `isActive()`
  `true` while the scan is running.
  `protected void`
  `onStop()`
  Hook for `BluetoothLE` to unregister the handle and stop the platform scan when it was the last one; invoked exactly once from `stop()`.
  `void`
  `stop()`
  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, waitFor`

  ### Methods inherited from class Observable

  `addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BleScan

    protected BleScan()
    Created by `BluetoothLE`; application code receives instances from `startScan`.

- ## Method Details

  - ### stop

    public void stop()
    Stops this scan. The handle resolves with `true`; the underlying platform scan keeps running while other handles remain active. Calling `stop()` on an already ended scan is a no-op.

  - ### isActive

    public boolean isActive()
    `true` while the scan is running.

  - ### cancel

    public boolean cancel(boolean mayInterruptIfRunning)
    Equivalent to `stop()`.
    Overrides:
      `cancel` in class `AsyncResource<Boolean>`

  - ### onStop

    protected void onStop()
    Hook for `BluetoothLE` to unregister the handle and stop the platform scan when it was the last one; invoked exactly once from `stop()`.