Bluetooth Socket not connecting android bluetooth -


i want connect 2 android devices via bluetooth,but not connecting @ all. here code connect far.....what can done,i have searched on internet have no solution yet....... kindly me out

// unique uuid application   private static uuid my_uuid_secure =     uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb");     private static uuid   my_uuid_insecure=uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb");  private class connectthread extends thread {     private final bluetoothsocket mmsocket;     private final bluetoothdevice mmdevice;     private string msockettype;      public connectthread(bluetoothdevice device, boolean secure) {         mmdevice = device;         bluetoothsocket tmp = null;         msockettype = secure ? "secure" : "insecure";          system.out.println("uuid created "+my_uuid_secure);         // bluetoothsocket connection         // given bluetoothdevice         try {              if (secure) {                  method m = device.getclass().getmethod("createrfcommsocket", new  class[] { int.class });                  tmp = (bluetoothsocket)m.invoke(mmdevice,integer.valueof(1));                 tmp = device.createrfcommsockettoservicerecord(                         my_uuid_secure);                 system.out.println("mm socket value :-"+tmp);             } else {                 tmp = device.createinsecurerfcommsockettoservicerecord(                         my_uuid_insecure);                 system.out.println("mm socket value :-"+tmp);             }         } catch (ioexception e) {             log.e(tag, "socket type: " + msockettype + "create() failed", e);         } catch (nosuchmethodexception e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (illegalargumentexception e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (illegalaccessexception e) {             // todo auto-generated catch block             e.printstacktrace();         } catch (invocationtargetexception e) {             // todo auto-generated catch block             e.printstacktrace();         }         mmsocket = tmp;     }      public void run() {         log.i(tag, "begin mconnectthread sockettype:" + msockettype);         setname("connectthread" + msockettype);          // cancel discovery because slow down connection         madapter.canceldiscovery();          // make connection bluetoothsocket         try {             // blocking call , return on             // successful connection or exception               system.out.println("new value socket value :-"+mmsocket);                          mmsocket.connect();         } catch (ioexception e) {             // close socket             try {                  mmsocket.close();             } catch (ioexception e2) {                 log.e(tag, "unable close() " + msockettype +                         " socket during connection failure", e2);             }             connectionfailed();             return;         }          // reset connectthread because we're done         synchronized (sharecontactservice.this) {             mconnectthread = null;         }          // start connected thread         connected(mmsocket, mmdevice, msockettype);     }       public void cancel() {         try {             mmsocket.close();         } catch (ioexception e) {             log.e(tag, "close() of connect " + msockettype + " socket failed", e);         }     } }  /**  * thread runs during connection remote device.  * handles incoming , outgoing transmissions.  */ 


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -