Package 

Class BluetoothManager


  • 
    public final class BluetoothManager
    
                        

    Helper class to manage bluetooth settings.

    • Method Summary

      Modifier and Type Method Description
      final Unit registerEnableListener(ComponentActivity componentActivity, Function0<Unit> onSuccess, Function0<Unit> onFailure) Registers a listener for bluetooth requests.
      final Unit registerEnableListener(Fragment fragment, Function0<Unit> onSuccess, Function0<Unit> onFailure) Registers a listener for bluetooth requests.
      final Unit requestEnable() Launches intent to ask user for turning on their bluetooth.
      final Unit onDestroy() Unregisters all listeners and destroys all related instances.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BluetoothManager

        BluetoothManager()
    • Method Detail

      • registerEnableListener

         final Unit registerEnableListener(ComponentActivity componentActivity, Function0<Unit> onSuccess, Function0<Unit> onFailure)

        Registers a listener for bluetooth requests.

        This must only be called once.

        Recommended calling this method in your activity's onCreate method.

        Parameters:
        componentActivity - ComponentActivity instance.
        onSuccess - Callback when user turns on their bluetooth.
        onFailure - Callback when user does not turn on their bluetooth.
      • registerEnableListener

         final Unit registerEnableListener(Fragment fragment, Function0<Unit> onSuccess, Function0<Unit> onFailure)

        Registers a listener for bluetooth requests.

        This must only be called once.

        Recommended calling this method in your fragment's onCreateView method.

        Parameters:
        fragment - Fragment instance.
        onSuccess - Callback when user turns on their bluetooth.
        onFailure - Callback when user does not turn on their bluetooth.
      • requestEnable

         final Unit requestEnable()

        Launches intent to ask user for turning on their bluetooth.

        This will display a dialog over the application.

      • onDestroy

         final Unit onDestroy()

        Unregisters all listeners and destroys all related instances.

        Invoke this in your activity / fragment onDestroy method.