Question: I have an activity and a handler created inside its onCreate function which looks like this:

```
private Handler mHandler;
private Button helloBtn;
private TextView helloText;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(...);

    helloBtn = (Button)findViewById(R.id.hello);
    helloBtn.setOnClickListener(this);
    helloText = (TextView)findViewById(R.id.text);

    mHandler = new Handler()
    {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what){
                case MSG_REPORT_PROGRESS:
                    int progress = msg.arg1;
                    seekBar.setProgress(progress);
                    break;
                case MSG_HELLO:
                    helloText.setText("hello world");
                    break;
            }
        }
    };
}
public void onClick(View view) {
    if(view == helloBtn)
    {
        Handler mainHanlder = new Handler(Looper.getMainLooper());
        Message msg = new Message();
        msg.what = MSG_HELLO;
        mainHandler.sendMessage(msg);
    }

}

```

the mainHandler didn't receive message when helloBtn been clicked. Why? it works if I directly use mHandler to replace the mainHandler, why?

Answer: 
use the below code.. and let me know the feedback. To show the text, handler is not needed. 

```
/** The m handler. */
private Handler mHandler;

/** The hello btn. */
private Button helloBtn;

/** The hello text. */
private TextView helloText;

/** The msg hello. */
private final int MSG_HELLO = 2;

/*
 * (non-Javadoc)
 * 
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    helloBtn = (Button) findViewById(R.id.btn_hello);
    helloBtn.setOnClickListener(this);
    helloText = (TextView) findViewById(R.id.txt_hello);

    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case MSG_HELLO:
                helloText.setText("hello world");
                break;
            }
        }
    };
}

/*
 * (non-Javadoc)
 * 
 * @see android.view.View.OnClickListener#onClick(android.view.View)
 */
public void onClick(View view) {
    if (view.getId() == R.id.btn_hello) {
        Message msg = new Message();
        msg.what = MSG_HELLO;
        mHandler.sendMessage(msg);
    }
}

```
The class Message has a field "target" which is used to store the handler that you used to send message. When you call a Handler's sendMessage(msg) method, the reference of the handler will be stored in the message. When the Looper dispatch your message it'll call msg.target.dispatchMessage(msg), which means that your msg will be dispatched to the same handler that you used to send it. The method dispatchMessage(msg) will call handleMessage(msg) eventually.

You can use a BroadcastReceiver to solve your problem. Register a BroadcastReceiver in the Activity that you want to update in the future, and send a Broadcast to it from the other part of you app.