The central management class in the SDK is Manager (or BleManager if you are working in BLE mode) as shown in the table:


Methods

Method

Name

Description

Static

getInstance()

Initializes an instance of "Manager"

Void

BindService(Context context, OnBindServiceCallback callback)

Binds the service. The callback interface for this service binding state is callback.

Void

unBindService(Context context)


Unbinds the service. Is called when the program is terminated and is used to release resources.

Void

searchScanner(OnSearchCallback onSearchCallback)

Search for Bluetooth scanners, OnSearchCallback is the callback interface for search results.

Void

Connect()

Connects to the last saved Bluetooth scanner

Void

connect(String address)

Connects to a Bluetooth scanner; the MAC address of the scanner can be used as the address.

Void

stop()

Disconnects from the Bluetooth scanner

Void

sendCmd(int cmd)

Sends a single command

Void

obtainAllCmd()

Obtain all setup commands for the Bluetooh Scanner

Manager

setConnectStatusListener(ConnectStatusListener listener)

Adds a connection status listener to the Bluetooth scanner to watch for status changes

Manager

setErrorCallback(ErrorCallback iErrorListener)

Adds listeners to retrieve error messages

Void

setOnDataReceive(OnDataReceive onDataReceive)

Receives data from the Bluetooth scanner

Void

OpenCode128()

Open Code128

Void

CloseCode128()

Close Code128

Void

OpenCode39()

Open Code39

Void

CloseCode39()

Close Code39





Interface classes


OnBindServiceCallback


Name

Description

Void        

success()


The service was bound successfully

Void

fail()


Binding of the service failed.


ConnectStatusListener


Name

Description

Void        

connectionState(int state)


Status contains four states:

0: disconnected, 

1: connecting, 

2: connected, 

3: connection failed.


ErrorCallback


Name

Description

Void        

errorState(int state)

Status contains three states:

4: the device does not support Bluetooth, 

5: the Bluetooth is not enabled, 

6: the device address is invalid.


OnSearchCallback


Name

Description

Void        

begin()

Call this method when searching the scanner

Void

searchForDevice(BluetoothDevice device)


Call back this method when searching for Bluetooth

Void

finish()

This method is called when the search scanner finishes.