Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. public class ConnectThread extends Thread{
  2.  
  3. private final BluetoothSocket mmSocket;
  4. @SuppressWarnings("unused")
  5. private final BluetoothDevice mmDevice;
  6. public static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
  7.  
  8. public ConnectThread(BluetoothDevice device) {
  9. BluetoothSocket tmp = null;
  10. mmDevice = device;
  11. try {
  12. tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
  13. } catch (IOException e) { }
  14. mmSocket = tmp;
  15. }
  16.  
  17. public void run() {
  18.  
  19. BluetoothUtils.cancelDiscovery();
  20. try {
  21. mmSocket.connect();
  22. Log.i("Connection to device","Established!");
  23. } catch (IOException connectException) {
  24. try {
  25. mmSocket.close();
  26. Log.i("Connection to device","Failed!");
  27. } catch (IOException closeException) { }
  28. return;
  29. }
  30. //manageConnectedSocket(mmSocket);
  31. }
  32.  
  33. public void cancel() {
  34. try {
  35. mmSocket.close();
  36. } catch (IOException e) { }
  37. }
  38.  
  39. }
  40.  
  41. BluetoothUtils.getBluetoothAdapter().cancelDiscovery();
  42. for(int i=0;i<listDiscoveredDevices.size();i++) {
  43. if(listDiscoveredDevices.get(i).getName().equals("XT1032")) {
  44. ConnectThread connection = new ConnectThread(listDiscoveredDevices.get(i));
  45. connection.start();
  46. }
  47. }
  48.  
  49. 04-15 12:38:20.312: I/Connection to device(32423): Failed!
  50. 04-15 12:38:20.351: D/dalvikvm(32154): GC_CONCURRENT freed 367K, 6% free 8236K/8711K, paused 4ms+5ms, total 37ms
  51. 04-15 12:38:22.031: W/ProcessStats(250): Skipping unknown process pid 32450
  52. 04-15 12:38:22.406: D/AudioHardware(90): AudioHardware pcm playback is going to standby.
  53. 04-15 12:38:22.406: D/AudioHardware(90): closePcmOut_l() mPcmOpenCnt: 1
  54. 04-15 12:38:25.140: D/BluetoothEventLoop(250): Device property changed: F8:E0:79:3D:86:1D property: Connected value: false
  55. 04-15 12:38:25.195: I/BluetoothConnectionReceiver(17878): onReceive(context, Intent { act=android.bluetooth.device.action.ACL_DISCONNECTED flg=0x8000010 cmp=com.google.android.googlequicksearchbox/com.google.android.search.core.service.BluetoothConnectionReceiver (has extras) }, [BluetoothDevice: address=F8:E0:79:3D:86:1D, alias=null, name=XT1032, majorDeviceClass=512, deviceClass=524])
  56. 04-15 12:38:25.199: I/BluetoothClassifier(17878): Bluetooth Device Name: XT1032
  57. 04-15 12:39:13.605: D/dalvikvm(250): GC_CONCURRENT freed 1202K, 25% free 14750K/19655K, paused 50ms+8ms, total 124ms
  58. 04-15 12:41:18.300: W/ThrottleService(250): unable to find stats for iface rmnet0
  59. 04-15 12:43:43.507: D/GCM(22893): Ignoring attempt to send heartbeat on dead connection.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement