E/androidruntime (7200): uncaught handler:thread Thread-8 exiting due to uncaught exception
E/androidruntime (7200): Java.lang.RuntimeException:Can ' t create handler inside thread that have not called Looper.prepare ()
The reason is that Looper objects are not created by default in the main thread, and you need to call Looper.prepare () to enable Looper first.
Workaround:
public void Sendjson2server(final jsonobject mJs) {
Handler Mhandler = new Handler () {
@Override
public void Handlemessage (Message msg) {
TODO auto-generated Method Stub
Super.handlemessage (msg);
Pushserviceex.sendpublic (Mtopicserver, mjs.tostring ());
System.out.println (Mjs.tostring ());
}
};
Mhandler.sendemptymessagedelayed (0, 5000);
Pushserviceex.sendpublic (Mtopicserver, mjs.tostring ());
}
New Thread () {
public void Run () {
Looper.prepare ();
Mpst.startpushservice ();
Mpst. Sendjson2server (Qjson);//Send message to server on line
Looper.loop ();
}
}.start ();
Add the red two lines above.