That's because you are doing your infinite while
loop in the same thread as the looper! So this thread is kept busy and cannot receive messages...
You need to let the Looper's thread on its own.
Let's say you setup your looper thread like this:
class LooperThread extends Thread {
public Handler handler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
Log.i("New System", "handling Message "+msg.arg1);
}
};
Looper.loop();
}
}
LooperThread looper = new LooperThread();
looper.start();
Then you can send messages from any OTHER thread (the UI thread or any other one) just the same way as you did:
Handler handler = looper.handler;
Message m = handler.obtainMessage();
m.arg1 = order;
handler.sendMessage(m);
But don't do this from the same thread as the looper or it doesn't make any sense.