android - Can't send message to inner handler class from thread class -


let have following class...

 private class signalrconnection extends thread {          private final int connect = 0;         private final int stop = 1;          private signalrhandler signalrhandler = null;          @override         public void run() {             looper.prepare();             signalrhandler = new signalrhandler();             looper.loop();             signalrhandler.sendmessage(message.obtain(null, connect));         }          public void end() {             message msg = message.obtain(null, stop);             bundle bundle = new bundle();             bundle.putboolean(immortal, false);             msg.setdata(bundle);             signalrhandler.sendmessage(msg);         }          public void immortal() {             message msg = message.obtain(null, stop);             bundle bundle = new bundle();             bundle.putboolean(immortal, true);             msg.setdata(bundle);             signalrhandler.sendmessage(msg);         }          private class signalrhandler extends handler {              private final signalrclient client;              signalrhandler() {                 client = new signalrclient(getresources().getstring(r.string.notification_host), "issueshub");             }              @override             public void handlemessage(message msg) {                 switch (msg.what) {                     case connect:                         client.connect();                         break;                     case stop:                         /*                          * clean up, , terminate.                          */                         bundle b = msg.getdata();                         boolean isimmortal = b.getboolean(signalrservice.immortal);                          client.disconnect();                         if (isimmortal) {                             client.immortal();                         }                         break;                 }             }         } // end of signalrhandler     } // end of signalr connection 

and start by...

    signalrconn = new signalrconnection();     signalrconn.start(); 

the problem signalrhandler can't receive meassage sent main class.

i'm sure have done somethings wrong please advice...


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -