Copyright 2014 ConnectQuest, LLC 1 CQ Beacon Android SDK V2.0.1 Software Requirements: Android 4.3 or greater SDK Support Page: http://www.connectquest.com/app- developers/android- api/ The CQ SDK package ships with the following classes: com.cq.android.sdk.connectquestsdk (CQ SDK main class) com.cq.android.sdk.domain.cqbeacon (CQ Beacon object) com.cq.android.sdk.domain.cqlistener (CQ listener interface) com.cq.android.sdk.service.ble.cqbleservice (CQ BLE scan service) com.cq.android.sdk.util.cqconstants (CQ Constants and Messages) We highly encourage you to try our sample app (available for download from the support page) and explore the source of the app and how the SDK is being utilized to build the app. The sample app (CQ Beacon Explorer, screenshots below) is a simple List- >Detail type Android app, built to support multiple handsets and screen sizes, uses the CQ SDK to scan for BLE devices every 60 seconds. When a BLE device is found, it is then added to the list of found devices and displayed on the screen. The user can then select the device from the list and see more information about the device, such as date & time when it was discovered, RSSI, Mac Address and other values.
Copyright 2014 ConnectQuest, LLC 2 CQ Demo App Screeshots: In order to use the API copy the SDK folder (com.cq.android.sdk) to your project and reference the following SDK classes from your activity: import com.cq.android.sdk.connectquestsdk; import com.cq.android.sdk.domain.cqbeacon; import com.cq.android.sdk.domain.cqlistener; import com.cq.android.sdk.util.cqconstants; Make sure the application manifest has the following permissions: <uses-permission android:name="android.permission.bluetooth"></uses-permission> <uses-permission android:name="android.permission.bluetooth_admin"></uses-permission> <uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
Copyright 2014 ConnectQuest, LLC 3 Your implementation will need to define and implement the following CQ SDK listener methods: public interface CQListener * Called when a non-cq BLE beacon has been discovered * @param beacon CQBeacon void handlegenericbeacondiscovery(cqbeacon beacon); * Called when a CQ BLE beacon has been discovered * @param beacon CQBeacon void handlecqbeacondiscovery(cqbeacon beacon); * Called when the BLE scan has stopped void handlestopbeacondiscovery(); * Called when the BLE scan has started void handlestartbeacondiscovery(); * Called when the BLE scan has stopped. * All found BLE beacons (CQ or generic) are passed.. * @param container Hashmap containing all found BLE void handlereceivefoundbeacons(map<string,cqbeacon> c); * Current activity application context * @return Context getcontext();
Copyright 2014 ConnectQuest, LLC 4 Here s a sample implementation of the listener (from the CQ BLE Demo app). The listener will handle BLE Beacon discovery calls. From the listener you can then call your data services, refresh UI, make database calls, etc * CQ Beacon Listener Implementation private CQListener cqsdklistener = new CQListener() public void handlegenericbeacondiscovery(cqbeacon c).. public void handlecqbeacondiscovery(cqbeacon beacon).. public void handlestopbeacondiscovery().. public void handlestartbeacondiscovery().. public Context getcontext() return getactivity(); Once you have the CQ Listener defined and implemented you can then instantiate the main SDK class and pass the listener to the SDK: //instantiate a new CQ SDK instance and pass the listener ConnectQuestSDK connectquestsdk = new ConnectQuestSDK(cqSDKListener, CQConstants.DISCOVERY_ONLY); and begin Beacon discovery: //start discovery connectquestsdk.startdiscovery();
Copyright 2014 ConnectQuest, LLC 5 Any SDK messages and configuration, such as BLE scan interval settings, can be customized in the com.cq.android.sdk.util.cqconstants class: * BLE Discovery and Data Retrieval public final static int DISCOVERY_AND_DATA_RETRIEVAL = 1; * BLE Discovery Only public final static int DISCOVERY_ONLY = 2; * Perform scan every 60 seconds public static final long BLE_SCAN_INTERVAL = 60000; * Stop scanning after 5 seconds public static final long BLE_SCAN_STOP_AFTER_PERIOD = 5000; * Not supported message public static final String BLE_NOT_SUPPORTED = "BLE is not supported on this device."; * Service not initialized message public static final String BLE_NOT_INITIALIZED = "BLE Scan Service has not been initialized."; * BT not enabled message public static final String BLUETOOTH_NOT_ENABLED = "Bluetooth not enabled. Please enable Bluetooth."; * CQ Beacon identifier (version 2) public static final String CQ_BEACON_IDENTIFIER_V2 = "cq"; * CQ Beacon identifier (version 2) public static final String CQ_BEACON_IDENTIFIER_V1 = "connect quest";