views:

28

answers:

1

How do I specify the destination of sendMessage() as logTextBox() in the example below?

public class Controller extends Activity {
    public Handler hLogTextBox = new Handler();
    ...
    public void listener() {
        String s = "my string";
        android.os.Message osMessage = hLogTextBox.obtainMessage();
        Bundle b = new Bundle();
        b.putString(null, s);
        osMessage.setData(b);
        hLogTextBox.sendMessage(osMessage);
    }
    ...
    public void logTextBox(String s) {
        ...
    }
    ...
}
+1  A: 

Got it... Controller.listener() sends osMessage to hLogTextBox.handleMessage()

public Handler hLogTextBox = new Handler() {
    @Override
    public void handleMessage(android.os.Message osMessage) {
        ...
    }
};
JackN