Reputation: 1507
So Im following the tutorial here: http://www.marioalmeida.eu/2014/02/21/how-to-do-android-ipc-using-messenger-to-a-remote-service/#comment-366
At the section just above Remote Service Manifest it talks about the service replying to activity by passing a bundle into a message using this code
Messenger mess = msg.replyTo; //retrieves messenger from the message
Message m = new Message(); //create the message to send back to the client
Bundle b = new Bundle(); //Just to show how to send other objects with it
b.putString(“messengerName”, “messenger1″); //this could be any parceable object
m.setData(b); //adds the bundle to the message
mess.send(m); //sends message
Im not sure how this works. Im looking at the android handler. It seems to differentiate the messages based on the what value. But If I follow the above then there is no what value (that I can see). All that is sent is the bundle. So what is in the what value for a message where it sends a bundle? If its empty how do i differentiate between messages sent with a bundle and ones sent using obtain?
Upvotes: 0
Views: 1294
Reputation: 7306
I follow the above then there is no what value (that I can see).
The message WHAT type has been set here :
Message msg = Message.obtain(null, MSG_REGISTER, 0, 0);
Please check this method :
public static Message obtain (Handler h, int what, int arg1, int arg2)
Parameters
h The target value to set.
what The what value to set.
arg1 The arg1 value to set.
arg2 The arg2 value to set.
Returns
A Message object from the global pool.
Upvotes: 1