As the below, I created 2 inner classes which both extend Handler
. I have read the code in Android source files, found Handler.sendEmptyMessage()
only enqueued the message in the Looper
's message queue.
public class MainActivity extends Activity{
private Handler handler = new Handler(Looper.getMainLooper()){
public void handleMessage(Message msg){
//handle method1
}
}
......
}
public class MyService extends Service{
private Handler handler = new Handler(Looper.getMainLooper());
public void test(){
handler.sendEmptyMessage(0x00);
}
......
}
So, I am confusing about why the first Handler
in MainActivity
cannot handle the message from the second Handler
in MyService
when the constructed with the same looper?