class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
Looper.loop();
// The rest of the code below is a control loop
}
}
关于什么可能导致Looper.loop()永不返回的想法?
答案 0 :(得分:7)
Looper.loop
会创建一个无限循环,只有在您调用quit
http://developer.android.com/reference/android/os/Looper.html#loop()
答案 1 :(得分:-2)
这可能有用
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
while(true){
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
}
// The rest of the code below is a control loop
}
}