android - Why doesn't mConnectThread.start() make the program proceed to the ConnectThread class? -


i'm struggling bluetooth communication between android phone , arduino bluetooth module (hc-06). i'm having trouble continuity of code. if start debugging, there no problem @ until program reaches mconnectthread.start(); line. @ point "stops": stays in debug mode i'm pressing step on in vain, not proceed. apparently doesn't jump connectthread class , don't have clue why occurs.

thank in advance!

public class mainactivity extends appcompatactivity {  private bluetoothadapter mbluetoothadapter; private bluetoothdevice mdevice; private connectthread mconnectthread; private string mac = "30:14:10:17:06:93";  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      textview supportsbtornot = (textview) findviewbyid(r.id.supportsbtornot);     textview listpaireddevices = (textview) findviewbyid(r.id.listpaireddevices);      mbluetoothadapter = bluetoothadapter.getdefaultadapter();      if (mbluetoothadapter == null) {         supportsbtornot.settext("the device not support bluetooth.");     }     else{         if (!mbluetoothadapter.isenabled()) {             intent enablebtintent = new intent(bluetoothadapter.action_request_enable);             startactivityforresult(enablebtintent, 1);         }         else{             supportsbtornot.settext("the device supports bluetooth.");         }     }      set<bluetoothdevice> paireddevices = mbluetoothadapter.getbondeddevices();     listpaireddevices.settext(paireddevices.tostring());     if (paireddevices.size() > 0) {         (bluetoothdevice device : paireddevices) {             if(device.getaddress().equals(mac)) {                 mdevice = device;                 break;             }         }     }     if (mdevice == null) {         //device not paired yet         //need initiate connection request     }      mconnectthread = new connectthread(mdevice);     mconnectthread.start(); }   private class connectthread extends thread {      private final bluetoothsocket mmsocket;     private connectedthread mconnectedthread;     private final uuid my_uuid = uuid.fromstring("00001101-0000-1000-8000-00805f9b34fb");      textview socketconnected = (textview) findviewbyid(r.id.socketconnected);      public connectthread(bluetoothdevice device) {         bluetoothsocket tmp = null;         try {             tmp = device.createrfcommsockettoservicerecord(my_uuid);         } catch (ioexception e) { }         mmsocket = tmp;     }      public void run() {         mbluetoothadapter.canceldiscovery();         try {             mmsocket.connect();         } catch (ioexception connectexception) {             try {                 mmsocket.close();             } catch (ioexception closeexception) { }             return;         }         if (mmsocket.isconnected()) {             socketconnected.settext("the socket established successfully.");         }         else {             socketconnected.settext("the socket not stablished.");         }          mconnectedthread = new connectedthread(mmsocket);         mconnectedthread.start();     } } 

calling thread.start() starts thread, debugger not jump new thread's context of execution. you'd have set breakpoint in run() method of thread step through that. calling start() @ end of oncreate() method, framework defined callback. after step on call start() or continue execution, oncreate() method returns , debugger not stop again until breakpoint hit.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -