public class ConfigurableDevicesScanner
extends java.lang.Object
DeviceConnectionProvider
.
It does not create a connection by itself, but provides ConfigurableDevice
data object
that can be used to obtain DeviceConnection
.
Note: This scanner should not be used for long term scanning (in background). It will drain battery quickly, because
it uses low latency scanning. It is intended to be used for displaying available devices in UI.
It should be started in Activity.onResume()
and stopped in Activity.onPause()
.
ConfigurableDevicesScanner deviceScanner = new ConfigurableDevicesScanner(context); // Scan for devices own by currently logged user. deviceScanner.setOwnDevicesFiltering(true); // Scan only for second generation beacons. deviceScanner.setDeviceTypes(DeviceType.LOCATION_BEACON); deviceScanner.scanForDevices(new ConfigurableDevicesScanner.ScannerCallback() { @Override public void onDevicesFound(Listdevices) { for(ScanResultItem item : devices) { displayDevice(item.device); } } });
Modifier and Type | Class and Description |
---|---|
static interface |
ConfigurableDevicesScanner.ScannerCallback |
static class |
ConfigurableDevicesScanner.ScanResultItem
Information about configurable device that was found during scanning.
|
Constructor and Description |
---|
ConfigurableDevicesScanner(android.content.Context context)
Constructs new scanner based on Context object.
|
Modifier and Type | Method and Description |
---|---|
void |
disableBulkFirmwareUpdate()
Stops bulk updater from updating firmware
|
void |
enableBulkFirmwareUpdate(BulkUpdater.BulkUpdaterCallback callback)
Enables bulk updater
|
boolean |
isOwnDevicesFiltering() |
boolean |
isScanning()
Returns if scan is in progress
|
boolean |
scanForDevices(ConfigurableDevicesScanner.ScannerCallback callback)
Starts scanning for configurable devices.
|
void |
setDeviceTypes(java.util.Collection<DeviceType> deviceTypes)
Sets types of accepted configurable devices.
|
void |
setDeviceTypes(DeviceType... deviceTypes)
Sets types of accepted configurable devices.
|
void |
setOwnDevicesFiltering(boolean ownDevicesFiltering)
Sets filtering for owned devices.
|
void |
setScanPeriodMillis(long scanPeriodMillis)
Sets scan period.
|
void |
stopScanning()
Stops configurable devices scanning (only when it was previously started).
|
public ConfigurableDevicesScanner(android.content.Context context)
context
- Android context object.public void setDeviceTypes(java.util.Collection<DeviceType> deviceTypes)
deviceTypes
- Collection of supported device types.public void setScanPeriodMillis(long scanPeriodMillis)
scanPeriodMillis
- Scan period in milliseconds.public void setDeviceTypes(DeviceType... deviceTypes)
deviceTypes
- Array of supported device types.public boolean isOwnDevicesFiltering()
public void setOwnDevicesFiltering(boolean ownDevicesFiltering)
EstimoteSDK.initialize(Context, String, String)
.ownDevicesFiltering
- If true only devices owned by user will be returned by scanner.public void enableBulkFirmwareUpdate(BulkUpdater.BulkUpdaterCallback callback)
public void disableBulkFirmwareUpdate()
public boolean scanForDevices(ConfigurableDevicesScanner.ScannerCallback callback)
callback
- Callback object that will be returning found devices.public boolean isScanning()
public void stopScanning()