public enum BleScanApi extends java.lang.Enum<BleScanApi>
ScanSettings
and a way to
force pre-Lollipop scanning mode. Provide an option to BleManagerConfig.scanApi
.Enum Constant and Description |
---|
AUTO
This option is recommended and will let SweetBlue automatically choose what scanning api to use
based on whether the app is backgrounded, if we're doing a long-term scan, polling scan, etc.
|
CLASSIC
Will force SweetBlue to use
BluetoothAdapter.startDiscovery() , which is so-called "Bluetooth Classic" discovery. |
POST_LOLLIPOP
This will tell SweetBlue to use the newer scanning API introduced in Lollipop
(
BluetoothLeScanner.startScan(List, ScanSettings, ScanCallback) ) . |
PRE_LOLLIPOP
This forces the use of the pre-Lollipop scanning API
BluetoothAdapter.startLeScan(BluetoothAdapter.LeScanCallback) ,
which was deprecated in Lollipop. |
Modifier and Type | Method and Description |
---|---|
static BleScanApi |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static BleScanApi[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final BleScanApi AUTO
public static final BleScanApi CLASSIC
BluetoothAdapter.startDiscovery()
, which is so-called "Bluetooth Classic" discovery.
This is the scanning mode used on the Android Bluetooth Settings screen. It only returns the mac address and name of your
device through a ScanFilter.ScanEvent
, as opposed to full LE scanning packets
which usually have a service UUID
(at the least) as well.public static final BleScanApi PRE_LOLLIPOP
BluetoothAdapter.startLeScan(BluetoothAdapter.LeScanCallback)
,
which was deprecated in Lollipop. This is the default API that SweetBlue uses, as it was found to be more effective at
discovering devices than the API introduced in Lollipop.public static final BleScanApi POST_LOLLIPOP
BluetoothLeScanner.startScan(List, ScanSettings, ScanCallback)
) . We've found that this API is
not yet as good as it's predecessor. It may be better for battery life, as you have more control over the scanning power (using
BleScanPower
), however, even at BleScanPower.HIGH_POWER
, we've found that it doesn't discover devices
as reliably as the pre-lollipop scan API.public static BleScanApi[] values()
for (BleScanApi c : BleScanApi.values()) System.out.println(c);
public static BleScanApi valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null