Hi All,
I am trying to establish a server (J2SE) and client (Android). The
client will send a string over to the server over Bluetooth.
For Android the code snippet is as below:
BluetoothAdapter adapter = null;
adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = adapter.getRemoteDevice(address);
//I have hardcode the server bluetooth mac address
adpter.enable();
BluetoothSocket socket = null;
socket = device.createRfcommSocketToServiceRecord(MY_UUID);
socket.connect();
sendMessage(socket, "Hello Bluetooth");
//sendMessage is just a method I have created
For the J2SE there is no BluetoothSocket (or is there?) I used
StreamConnection. The code snippet is as below:
StreamConnectionNotifier con = (StreamConnectionNotifier)
Connector.open("btspp://localhost:"+UUID
+name=example;authorise=false");
StreamConnection Strconn = con.acceptAndOpen();
InputStream input = conn.openInputStream();
System.out.println(input);
input.close();
conn.close();
I am not sure whether an Android app can send a string over to a J2SE
application by Bluetooth. Could not find any reference online. Is it
possible?
If possible is what I am doing above the correct method? Because I
receive nothing over at the server side (J2SE). I not sure is it
because I am using BluetoothSocket in android and StreamConnection for
J2SE. Is it?
Thanks In Advance,
Perumal
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en