2014-11-21 113 views
0

因此,進出口教程這裏如下:http://www.marioalmeida.eu/2014/02/21/how-to-do-android-ipc-using-messenger-to-a-remote-service/#comment-366在消息傳遞捆綁

在略高於遠程服務清單中的部分就談到了服務通過使用此代碼

通過捆綁到消息回覆活動
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 

我不知道這是如何工作的。我看着android處理程序。它似乎根據什麼價值區分消息。但如果我遵循上面的話,那麼就沒有什麼價值(我可以看到)。所有發送的都是捆綁包。那麼,發送一個包的消息有什麼價值?如果它是空的,我如何區分使用bundle發送的消息和使用gets發送的消息?

+0

你只是關注*什麼*消息淡水河谷? – 2014-11-21 05:13:24

回答

1

我按照上面那麼沒有什麼價值(我可以看到)。

消息什麼類型已經在這裏設置:

Message msg = Message.obtain(null, MSG_REGISTER, 0, 0); 

請檢查此方法:

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. 
+0

啊,好吧。涼。乾杯。這是破壞我的頭。我認爲他們是發送消息的兩種獨立方法,但是它具有不同值的相同消息,對嗎? – discodowney 2014-11-21 16:05:59

+0

是的... MSG_REGISTER的值將在所有情況下設置。 – 2014-11-22 03:53:27

+0

感謝隊友,我現在正在工作。好人!! – discodowney 2014-11-25 02:03:15