Welcome! Sign in or Register to get your developer token.




Installation Connecting Reading Stats Types

Android SDK

Installation Connecting Reading Stats Types

React Native

Demo App




Before the BACtrack API can be used to communicate with a BACtrack device, it must first be initialized, like so:

BACtrackAPI bacTrackAPI = new BACtrackAPI(this, callbacks, apiKey)

This constructor creates a BACtrackAPI object with the passed-in BACtrackAPICallbacks object. Additionally, it checks with our server whether the included API Key is valid. In case your app has not been approved to use our SDK, the following required callback will be called:

void BACtrackAPIKeyDeclined(String errorMessage)

Connecting to Nearest Device

Once you’ve created your BacTrackAPI object, you can establish a Bluetooth LE connection between your Android device and your BACtrack by executing the following command call on the BACtrackAPI object: public void connectToNearestBreathalyzer()

Tapping on the “Take Test” button calls public boolean startCountdown() on the BacTrackAPI object and initiates a series of callbacks on the BacTrackAPIDelegate shown below.

Connecting to a Selected Device

In order to connect to a selected device, you must first scan for it. Call startScan(), and wait for the BACtrackFoundBreathalyzer() callback to come in. The scan will continue until stopScan() is called.

Once the BACtrackFoundBreathalyzer() callback comes in with the BACtrackDevice you would like to connect to, call connectToDevice(), passing in the BACtrackDevice object.

API Reference


public BACtrackAPI(Context context, final BACtrackAPICallbacks bacTrackAPICallbacks, String apiKey) Constructs an instance of the BACtrack API, with a given set of callbacks and an API key.

Expect one of the following callbacks, depending on whether or not the API key was valid:

Connect to Nearest Breathalyzer

public void connectToNearestBreathalyzer() Connect to the nearest BACtrack device with no scanning timeout. Expect either BACtrackConnected() or BACtrackConnectionTimeout().

Connect to Nearest Breathalyzer with Timeout

public void connectToNearestBreathalyzerWithTimeout() Connect to the nearest BACtrack device found after a one-second scan. See connectToNearestBreathalyzer() for more information.

Scan for Devices

public void startScan() Scans for BACtracks within range. Continues until stopScan() is called.

Stop Scanning for Devices

public ArrayList<BACtrackDevice> stopScan() Stop scanning for devices. Returns an array of breathalyzers found by the scan, which can then be connected to using connectToDevice(BACtrackDevice),

Connect to a Specific Breathalyzer

public void connectToDevice(BACtrackDevice breathalyzer) Alternate use case for connecting to a BACtrack device. You can retrieve a breathalyzer instance by using startScan and stopScan()

Disconnect from Device

public void disconnect() Disconnect from the currently-connected BACtrack device.

Callback Reference

API Key Authorized

void BACtrackAPIKeyAuthorized() Called during construction if the API key is valid.

API Key Declined (Required)

void BACtrackAPIKeyDeclined(String errorMessage) Called during construction if the API key is invalid or otherwise declined.

BACtrack Connected

void BACtrackDidConnect(String breathalyzerAdvertisedName) Called after the BACtrack is connected but before services are discovered.

BACtrack Ready

void BACtrackConnected(BACTrackDeviceType bacTrackDeviceType) Called after the BACtrack is connected and services are discovered.

BACtrack Connection Timed Out

void BACtrackConnectionTimeout() Called if a connection attempt times out.

BACtrack Disconnected

void BACtrackDisconnected() Called when the BACtrack disconnects from the Android device.

BACtrack Device Discovered

void BACtrackFoundBreathalyzer(BACtrackDevice breathalyzer) Called whenever a BACtrack device is found while scanning for a device. You can use this callback to register a list of BACtrack devices in your app, or you can use the result of the stopScan() API call, which returns a list of discovered devices.