Android Bluetooth COM port

androidbluetooth

I have spent some time researching Android's ability to communicate with bluetooth devices that are designed to communicate over a Bluetooth COM port on a PC. I haven't been able to find a definitive answer, so I thought I'd ask here. I want to make sure that this is possible with Android.

I am new to Bluetooth communications, but the research I've done so far lead me to RFCOMM which somewhat sounded like what I wanted. Unfortunately, I'm still unable to confirm that this is in fact possible.

Any help/resources on this would be greatly appreciated.

Best Solution

Yes, Android can connect to Bluetooth COM ports on PC's. I am currently developing such an application. Here is a code example (Ite requires the bluetooth permissions te be set in the Manifest.xml file):

<uses-permission android:name="android.permission.BLUETOOTH" />

Java:

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter == null) {
    // Device does not support Bluetooth
    finish(); //exit
}

if (!adapter.isEnabled()) {
//make sure the device's bluetooth is enabled
    Intent enableBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBluetooth, REQUEST_ENABLE_BT);
}

final UUID SERIAL_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); //UUID for serial connection
mac = "00:15:83:3D:0A:57"; //my laptop's mac adress
device = adapter.getRemoteDevice(mac); //get remote device by mac, we assume these two devices are already paired


 // Get a BluetoothSocket to connect with the given BluetoothDevice
BluetoothSocket socket = null;
OutputStream out = null;
try {
    socket = device.createRfcommSocketToServiceRecord(SERIAL_UUID); 
} catch (IOException e) {}

try {           
    socket.connect(); 
    out = socket.getOutputStream();
    //now you can use out to send output via out.write
} catch (IOException e) {}