STWBluetooth State Manager
STWBluetoothStateManager
Description :
This class represent the API for all actions/event related to Bluetooth.
This class offers several possible operations defined in the following list :
- Bluetooth turn On
- Bluetooth turn Off
- Bluetooth Device Connected
- Bluetooth Device Disconnected
Example of use
To add the Support of SWhardware module to your project, include the following line in the dependencies block of your build.gradle file:dependencies { implementation project(':swhardware') }Content copied to clipboardContent copied to clipboardSTWBluetoothStateManager.getInstance().registerForBluetoothStateCallback(getContext(), new IBluetoothStateCallback() { public void getLastConnectedBluetoothDeviceAddress() { //Code... } public void onBluetoothTurnedOff() { //Code... } public void onBluetoothTurnedOn() { //Code... } public void onDeviceConnected() { //Code... } public void onDeviceDisconnect() { //Code... } });Content copied to clipboardSTWBluetoothStateManager.getInstance().unregisterForBluetoothStateCallback(IBluetoothStateCallback);Content copied to clipboard
Functions
Link copied to clipboard
Link copied to clipboard
open fun registerForBluetoothStateCallback(@NonNull context: Context, @Nullable bluetoothStateCallback: IBluetoothStateCallback)
Content copied to clipboard
Register the specified callback to be notified by Bluetooth state/ Device State.
Link copied to clipboard
UnRegister the specified callback to not receive Bluetooth state/ Device State event.