public final class Cubeacon
extends java.lang.Object
CBBootstrapRegion
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD
The default duration in milliseconds spent not scanning between each Bluetooth scan cycle
when no ranging/monitoring clients are in the foreground
|
static long |
DEFAULT_BACKGROUND_SCAN_PERIOD
The default duration in milliseconds of the Bluetooth scan cycle when no
ranging/monitoring clients are in the foreground
|
static long |
DEFAULT_EXIT_PERIOD
The default duration in milliseconds of region exit time
|
static long |
DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD
The default duration in milliseconds spent not scanning between each Bluetooth scan cycle
|
static long |
DEFAULT_FOREGROUND_SCAN_PERIOD
The default duration in milliseconds of the Bluetooth scan cycle
|
Modifier and Type | Method and Description |
---|---|
void |
addMonitoringListener(CBMonitoringListener listener)
Specifies an interface listener that should be called each time the BeaconService
sees or stops seeing a
CBRegion of beacons. |
void |
addRangingListener(CBRangingListener listener)
Specifies an interface that should be called each time the BeaconService
gets ranging data, which is nominally once per second when beacons are detected.
|
void |
connect(CBServiceListener listener)
Connect an Android Activity or Service to the
BeaconService.
|
void |
disconnect(CBServiceListener listener)
Disconnect an Android Activity or Service from the
BeaconService.
|
static Cubeacon |
getInstance()
Gets the instance of Cubeacon SDK.
|
static java.lang.String |
getSDKVersion()
Shows Cubeacon SDK version string.
|
static void |
initialize(android.content.Context context)
Initialize Cubeacon SDK.
|
boolean |
isConnected(CBServiceListener listener)
Check if the passed service listener is bound to the service.
|
static boolean |
isInitialized()
Check whether Cubeacon SDK is initialized.
|
void |
removeMonitoringListener(CBMonitoringListener listener)
Specifies a class to remove from the array of CBMonitoringListener.
|
void |
removeMonitoringListeners()
Remove all registered monitoring listeners.
|
void |
removeRangingListener(CBRangingListener listener)
Specifies an interface to remove from the array of CBRangingListener
|
void |
removeRangingListeners()
Remove all registered ranging listeners.
|
void |
setBackgroundIntervalScanPeriod(long p)
Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons.
|
void |
setBackgroundMode(boolean backgroundMode)
This method notifies the beacon service that the application is either moving to background
mode or foreground mode.
|
static void |
setBackgroundPowerSaver(boolean flag)
Sets background power saver mode.
|
void |
setBackgroundScanPeriod(long p)
Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons.
|
void |
setForegroundIntervalScanPeriod(long p)
Sets the duration in milliseconds between each Bluetooth LE scan cycle to look for beacons.
|
void |
setForegroundScanPeriod(long p)
Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons.
|
static void |
setRegionExitPeriod(long period)
Set region exit period in milliseconds.
|
void |
startMonitoringForRegion(CBRegion region)
Tells the BeaconService to start looking for beacons that match the passed
CBRegion object.
|
void |
startMonitoringForRegions(java.util.List<CBRegion> regions)
Tells the BeaconService to start looking for beacons that match the passed list of
CBRegion object.
|
void |
startRangingBeaconsInRegion(CBRegion region)
Tells the BeaconService to start looking for beacons that match the passed
CBRegion object, and providing updates on the estimated distance every seconds while
beacons in the CBRegion are visible.
|
void |
startRangingBeaconsInRegions(java.util.List<CBRegion> regions)
Tells the BeaconService to start looking for beacons that match the passed
list of CBRegion object, and providing updates on the estimated distance every
seconds while beacons in the CBRegion are visible.
|
void |
stopMonitoringForRegion(CBRegion region)
Tells the BeaconService to stop looking for beacons that match the passed
CBRegion object.
|
void |
stopRangingBeaconsInRegion(CBRegion region)
Tells the BeaconService to stop looking for beacons that match the passed
CBRegion object.
|
void |
updateScanPeriods()
Updates an already running scan with scanPeriod/betweenScanPeriod according to
Background/Foreground state.
|
public static final long DEFAULT_FOREGROUND_SCAN_PERIOD
public static final long DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD
public static final long DEFAULT_BACKGROUND_SCAN_PERIOD
public static final long DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD
public static final long DEFAULT_EXIT_PERIOD
public static void initialize(android.content.Context context)
context
- The application contextpublic static Cubeacon getInstance()
public static boolean isInitialized()
public static java.lang.String getSDKVersion()
String
of Cubeacon SDK version.public static void setBackgroundPowerSaver(boolean flag)
flag
- true to enable background power savesetBackgroundMode(boolean)
public void setBackgroundMode(boolean backgroundMode)
When ranging in the background, the time between updates will be much less frequent than in the foreground. Updates will come every time interval equal to the sum total of the BackgroundScanPeriod and the BackgroundBetweenScanPeriod.
backgroundMode
- true indicates that app is in the backgroundDEFAULT_FOREGROUND_SCAN_PERIOD
,
DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD
,
DEFAULT_BACKGROUND_SCAN_PERIOD
,
DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD
,
setForegroundScanPeriod(long)
,
setForegroundIntervalScanPeriod(long)
,
setBackgroundScanPeriod(long)
,
setBackgroundIntervalScanPeriod(long)
public void setForegroundScanPeriod(long p)
connect(CBServiceListener)
or when switching between background/foreground. To have it effect on an already running
scan (when the next cycle starts), call updateScanPeriods()
p
- The foreground period to setpublic void setForegroundIntervalScanPeriod(long p)
connect(CBServiceListener)
or when switching between background/foreground. To have it effect on an already running scan
(when the next cycle starts), call updateScanPeriods()
p
- The foreground interval to setpublic void setBackgroundScanPeriod(long p)
connect(CBServiceListener)
or when switching between background/foreground. To have it effect on an already running scan
(when the next cycle starts), call updateScanPeriods()
p
- The background period to setpublic void setBackgroundIntervalScanPeriod(long p)
connect(CBServiceListener)
or when switching between background/foreground. To have it effect on an already running scan
(when the next cycle starts), call updateScanPeriods()
p
- The background interval to setpublic void updateScanPeriods() throws android.os.RemoteException
android.os.RemoteException
- If the Cubeacon is not connected to the service.public static void setRegionExitPeriod(long period)
period
- The period when region exitpublic void addMonitoringListener(CBMonitoringListener listener)
Specifies an interface listener that should be called each time the BeaconService
sees or stops seeing a CBRegion
of beacons.
Permits to register severals CBMonitoringListener objects.
Unregister the listener usingremoveMonitoringListener(CBMonitoringListener)
listener
- The monitoring listener interface to addCBMonitoringListener
,
startMonitoringForRegion(CBRegion)
,
CBRegion
public void removeMonitoringListener(CBMonitoringListener listener)
listener
- The monitoring interface listener to removeCBMonitoringListener
,
startMonitoringForRegion(CBRegion)
,
CBRegion
public void removeMonitoringListeners()
public void addRangingListener(CBRangingListener listener)
Specifies an interface that should be called each time the BeaconService gets ranging data, which is nominally once per second when beacons are detected.
Permits to register several CBRangingListener objects.
The listener must be unregistered usingremoveRangingListener(CBRangingListener)
listener
- The ranging interface listener to addCBRangingListener
,
startRangingBeaconsInRegion(CBRegion)
,
CBRegion
public void removeRangingListener(CBRangingListener listener)
listener
- The ranging interface listener to removeCBRangingListener
public void removeRangingListeners()
public void connect(CBServiceListener listener)
listener
- the Activity or Service that will receive
the callback when the service is ready.public void disconnect(CBServiceListener listener)
listener
- the Activity or Service that no longer needs
to use the service.connect(CBServiceListener)
public boolean isConnected(CBServiceListener listener)
listener
- The service listener to checkconnect(CBServiceListener)
,
disconnect(CBServiceListener)
public void startRangingBeaconsInRegion(CBRegion region) throws android.os.RemoteException
stopRangingBeaconsInRegion(CBRegion)
method.region
- The region to start rangingandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addRangingListener(CBRangingListener)
,
stopRangingBeaconsInRegion(CBRegion)
,
CBRangingListener
,
CBRegion
public void stopRangingBeaconsInRegion(CBRegion region) throws android.os.RemoteException
region
- The region to stop rangingandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addRangingListener(CBRangingListener)
,
startRangingBeaconsInRegion(CBRegion)
,
CBRangingListener
,
CBRegion
public void startRangingBeaconsInRegions(java.util.List<CBRegion> regions) throws android.os.RemoteException
stopRangingBeaconsInRegion(CBRegion)
method.regions
- The list of region to start rangingandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addRangingListener(CBRangingListener)
,
stopRangingBeaconsInRegion(CBRegion)
,
CBRangingListener
,
CBRegion
public void startMonitoringForRegion(CBRegion region) throws android.os.RemoteException
stopMonitoringForRegion(CBRegion)
method.region
- The region to start monitoringandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addMonitoringListener(CBMonitoringListener)
,
stopMonitoringForRegion(CBRegion)
,
CBMonitoringListener
,
CBRegion
public void stopMonitoringForRegion(CBRegion region) throws android.os.RemoteException
region
- The region to stop monitoringandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addMonitoringListener(CBMonitoringListener)
,
startMonitoringForRegion(CBRegion)
,
CBMonitoringListener
,
CBRegion
public void startMonitoringForRegions(java.util.List<CBRegion> regions) throws android.os.RemoteException
stopMonitoringForRegion(CBRegion)
method.regions
- The list of region to start monitoringandroid.os.RemoteException
- If the Cubeacon is not connected to the service.addMonitoringListener(CBMonitoringListener)
,
stopMonitoringForRegion(CBRegion)
,
CBMonitoringListener
,
CBRegion