我有一个要求,我有一个通过蓝牙连接到手机的配对设备列表。在某些时候,我必须禁用/启用将媒体或联系人详细信息共享到我的配对设备。我的要求是在 android 中以编程方式执行此操作。我已经搜索过这个,但我找不到任何解决方案。
请让我知道是否可能?
尝试
获取默认蓝牙适配器
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
使能够
bluetoothAdapter.enable();
禁用
bluetoothAdapter.disable();
检查状态
bluetoothAdapter.isEnabled();
只需尝试启用或禁用蓝牙。
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.disable();
}else {
mBluetoothAdapter.enable();
}