Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void serviceSearchCompleted(int arg0, int arg1) {
- debugString("Service search completed.");
- for(int ii=0;ii<4;ii++){
- broadcastCommand(new String("Hello world!"));
- }
- }
- /**
- * Sends a message to all the devices. (using the service)
- *
- * @param str
- * Byte array which represents a string.
- */
- public void broadcastCommand(String str) {
- for(ServiceRecord sr : services) {
- String url = sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
- conn = null;
- try {
- debugString("Sending command to " + url);
- conn = (StreamConnection) Connector.open(url);
- dout = new DataOutputStream(conn.openOutputStream());
- dout.writeUTF(str);
- debugString(String.format("Sending %s", str));
- dout.flush();
- dout.close();
- conn.close();
- debugString("Sent. Connection Closed.");
- } catch (Exception e) {
- debugString("Failed to connect to " + url);
- e.printStackTrace();
- }
- }
- }
- javax.bluetooth.BluetoothConnectionException:
- at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)
- at com.intel.bluetooth.BluetoothStackMicrosoft.access$700(BluetoothStackMicrosoft.java:44)
- at com.intel.bluetooth.BluetoothStackMicrosoft$ConnectThread.run(BluetoothStackMicrosoft.java:651)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement