4

我有一个要求,我有一个通过蓝牙连接到手机的配对设备列表。在某些时候,我必须禁用/启用将媒体或联系人详细信息共享到我的配对设备。我的要求是在 android 中以编程方式执行此操作。我已经搜索过这个,但我找不到任何解决方案。

请让我知道是否可能?

4

2 回答 2

1

尝试

获取默认蓝牙适配器

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

使能够

 bluetoothAdapter.enable(); 

禁用

bluetoothAdapter.disable(); 

检查状态

bluetoothAdapter.isEnabled();
于 2017-05-09T10:27:38.643 回答
1

只需尝试启用或禁用蓝牙。

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();    

            if (mBluetoothAdapter.isEnabled()) {
                mBluetoothAdapter.disable(); 
            }else {
                mBluetoothAdapter.enable(); 
            }
于 2017-05-09T10:17:10.713 回答