Last active
September 26, 2021 09:45
-
-
Save pritam-quantum-inventions/30c7d307f04fe08f4646b1d9c7895cd9 to your computer and use it in GitHub Desktop.
enable bluetooth adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun bluetoothWrapper(result: MethodChannel.Result) { | |
val defaultAdapter: BluetoothAdapter? = BluetoothAdapter.getDefaultAdapter() | |
if (defaultAdapter == null) { | |
result.error("Bluetooth adapter doesn't exist on this device", null, null) | |
} else { | |
result.success("bluetooth adapter exists on device") | |
} | |
defaultAdapter?.let { | |
val requestEnableBt = 1 | |
if (!bluetoothAdapter.isEnabled) { | |
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE) | |
startActivityForResult(enableIntent, requestEnableBt) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment