//Above android 12
Button(onClick = {
val intent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
activityResultLauncher.launch(intent)
}) {
Text(text = "Enable")
}
此代码帮助我在 Android 13+ 中启用蓝牙,但我不知道如何禁用它
我看到了 REQUEST_DISABLE 方法,我尝试了这个,但这是一个私有方法,所以它不起作用
Button(onClick = { val intent = Intent(android.bluetooth.adapter.action.REQUEST_DISABLE) activityResultLauncher.launch(intent) }) { Text(text = "disable") }
val bluetoothAdapter: BluetoothAdapter? = BluetoothAdapter.getDefaultAdapter()
bluetoothAdapter.disable()