相关疑难解决方法(0)

如何在Android中发送基于BT免提配置文件的AT命令?

我正在尝试通过免提配置文件在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 : " …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

bluetooth ×1