-
public final class BluetoothManager
Helper class to manage bluetooth settings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
BluetoothManager.Companion
-
Constructor Summary
Constructors Constructor Description BluetoothManager()
-
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. -
-
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.
-
-
-
-