Class 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().

  • 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().