RequireBluetooth

fun RequireBluetooth(onChanged: (Boolean) -> Unit = {}, contentWithoutBluetooth: @Composable (BlePermissionNotAvailableReason) -> Unit = { NoBluetoothView(reason = it) }, content: @Composable () -> Unit)

A wrapper for composables that require Bluetooth.

This composable will display a view based on the Bluetooth state and permissions.

On Android 12+ it will require BLUETOOTH_SCAN, BLUETOOTH_CONNECT and BLUETOOTH_ADVERTISE permission to be granted and will show a view allowing requesting them.

Example:

RequireBluetooth(
onChanged = { onScanningStateChanged(it) }
) {
RequireLocation(
onChanged = { onScanningStateChanged(it) }
) {
// Bluetooth scanner views
}
}

Parameters

onChanged

A callback that will be called when the state of the Bluetooth changes.

contentWithoutBluetooth

A composable that will be displayed when Bluetooth is not available.

content

A composable that will be displayed when Bluetooth is available.

See also