Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. @Override
  2. public void serviceSearchCompleted(int arg0, int arg1) {
  3. debugString("Service search completed.");
  4.  
  5. for(int ii=0;ii<4;ii++){
  6. broadcastCommand(new String("Hello world!"));
  7. }
  8. }
  9.  
  10. /**
  11. * Sends a message to all the devices. (using the service)
  12. *
  13. * @param str
  14. * Byte array which represents a string.
  15. */
  16. public void broadcastCommand(String str) {
  17. for(ServiceRecord sr : services) {
  18. String url = sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
  19.  
  20. conn = null;
  21.  
  22. try {
  23. debugString("Sending command to " + url);
  24.  
  25. conn = (StreamConnection) Connector.open(url);
  26. dout = new DataOutputStream(conn.openOutputStream());
  27.  
  28. dout.writeUTF(str);
  29. debugString(String.format("Sending %s", str));
  30.  
  31. dout.flush();
  32. dout.close();
  33. conn.close();
  34.  
  35. debugString("Sent. Connection Closed.");
  36.  
  37. } catch (Exception e) {
  38. debugString("Failed to connect to " + url);
  39. e.printStackTrace();
  40. }
  41. }
  42. }
  43.  
  44. javax.bluetooth.BluetoothConnectionException:
  45. at com.intel.bluetooth.BluetoothStackMicrosoft.connect(Native Method)
  46. at com.intel.bluetooth.BluetoothStackMicrosoft.access$700(BluetoothStackMicrosoft.java:44)
  47. at com.intel.bluetooth.BluetoothStackMicrosoft$ConnectThread.run(BluetoothStackMicrosoft.java:651)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement