我正在尝试在Handsfree配置文件下,使用以下代码在Android设备与其他手机之间建立蓝牙连接。
private static final UUID MY_UUID = UUID.fromString("0000111F-0000-1000-8000-00805F9B34FB"); // UUID for Hands free profile
// Some code...
// Get Bluetooth Adapter.
m_oBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
// Some code...
// For paired BT device, getting a connection established.
if(null != m_oBluetoothDevice)
{
if(BluetoothDevice.BOND_BONDED == m_oBluetoothDevice.getBondState())
{
try
{
m_oBluetoothSocket = m_oBluetoothDevice.createRfcommSocketToServiceRecord(MY_UUID);
m_oBluetoothSocket.connect();
Log.i(TAG, "Socket Connected");
}
catch(Exception e)
{
if(null != m_oBluetoothSocket)
{
Log.i(TAG, "Closing socket");
try
{
m_oBluetoothSocket.close();
}
catch (Exception e1)
{
Log.i(TAG, "Error while closing socket : " + e1.getMessage());
}
}
}
}
}
我可以使用以下代码创建RFCOMMSocket。
``` 我可以使用以下代码创建RFCOMMSocket。 ```现在,我想基于蓝牙免提配置文件发送AT命令。例如,如果其他手机接收到电话,我的Android设备可以通过发送AT命令"+CHUP"拒绝此通话。我不确定是否可能实现。
``` 现在,我想基于蓝牙免提配置文件发送AT命令。例如,如果其他手机接收到电话,我的Android设备可以通过发送AT命令"+CHUP"拒绝此通话。我不确定是否可能实现。 ```目前,我遇到了困难。我已经阅读了蓝牙API文档,其中发现了-
``` 目前,我遇到了困难。我已经阅读了蓝牙API文档,其中发现了- ``` BluetoothHeadset.ACTION_VENDOR_SPECIFIC_HEADSET_EVENT
我们能够使用这个Intent来发送AT指令吗?这是基于蓝牙免提配置文件发送AT命令的正确方式吗?请有人帮助我并给出适当的方向。
您所有的输入对我来说都将是巨大的帮助。
提前致谢。