STWBluetoothStateManager

open class STWBluetoothStateManager

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')
     }
    
  • 
            STWBluetoothStateManager.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...
         }
    
         });
    
  • 
            STWBluetoothStateManager.getInstance().unregisterForBluetoothStateCallback(IBluetoothStateCallback);
    

Functions

Link copied to clipboard
open fun getInstance(): STWBluetoothStateManager
Link copied to clipboard
open fun registerForBluetoothStateCallback(@NonNull context: Context, @Nullable bluetoothStateCallback: IBluetoothStateCallback)
Register the specified callback to be notified by Bluetooth state/ Device State.
Link copied to clipboard
open fun unregisterForBluetoothStateCallback(@NonNull context: Context)
UnRegister the specified callback to not receive Bluetooth state/ Device State event.