Android 如何通过蓝牙发送/接收字符串

Android 如何通过蓝牙发送/接收字符串,android,bluetooth,Android,Bluetooth,我有3个编辑文本。这些编辑文本中的数据连接到单个字符串。我想使用我的应用程序通过蓝牙将此字符串从我的手机发送到另一部手机中的同一应用程序 bluetooth manager和获取配对设备列表的代码为: if (!bluetoothAdapter.isEnabled()) { startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), 0); Intent

我有3个编辑文本。这些编辑文本中的数据连接到单个字符串。我想使用我的应用程序通过蓝牙将此字符串从我的手机发送到另一部手机中的同一应用程序

bluetooth manager和获取配对设备列表的代码为:

   if (!bluetoothAdapter.isEnabled()) {
            startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), 0);
            Intent getVisible = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
            startActivityForResult(getVisible, 0);
            Toast.makeText(this, "Bluetooth Turned ON", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "Bluetooth Alredy ON", Toast.LENGTH_LONG).show();
        }

       //show the list of paired devices...
        startActivity(new Intent(this,DeviceList.class));
   }
}

    public void list(View v){
        pairedDevices = bluetoothAdapter.getBondedDevices();
        ArrayList list = new ArrayList();

        for(BluetoothDevice bt : pairedDevices)
            list.add(bt.getName());
        Toast.makeText(getApplicationContext(),"Showing Paired Devices",Toast.LENGTH_SHORT).show();

        final ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
        lv.setAdapter(adapter);
    }
。现在,我想将该字符串从手机中的应用发送到另一部手机中的同一应用。这是假设我连接了两部手机(比如A和B)有这个应用程序。我想从a向B发送一个字符串(比如“123”)

我在网上浏览了一些教程。我所理解的是,这需要一个套接字和一个唯一的密钥来识别应用程序。我该怎么做?
请详细说明。

您只能通过设置的代码搜索可用的蓝牙设备。您是对的,您需要建立一个套接字连接才能与其他设备进行通信。实现此链接中示例中给出的代码,您应该能够在其他设备上看到您的字符串