我正在使用此代码将字符串发送到其他Android配对设备。输出是我需要发送的字符串,它被声明为public,但此代码无效。请帮我纠正这段代码
try{
BluetoothDevice[] devices = (BluetoothDevice[]) bondedDevices.toArray();
BluetoothDevice device = devices[0];
ParcelUuid[] uuids = device.getUuids();
BluetoothSocket socket= device.createRfcommSocketToServiceRecord(uuids[0].getUuid());
socket.connect();
OutputStream outputStream = socket.getOutputStream();
outputStream.write(output.getBytes());
Toast.makeText(getApplicationContext(), "Data Sent...", Toast.LENGTH_SHORT);
}
catch(Exception e){
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG);
}