asmack + openfire develop a android IM app. But I donn't known how to receive message from friends then dispatch to corresponding chat.
I had the follow function: connection the openfire server and login success(acount A). Then I have a 'FriendsActivity' show all friends in ListView, click the item then intent to 'ChatActivity'. In 'ChatActivity' I create a chat to acount B(or another acount).
chatManager.createChat(B, new MessageListener() {
@Override
public void processMessage(Chat chat2,
org.jivesoftware.smack.packet.Message msg) {
handler.obj = msg; //handler to updata the listview to show message history
}
}
The code help me implement chat with B, but A should click the item to 'ChatActivity' first.
How to receive message at 'FriendsActivity' and give diffrent hint like "you have a new message from acount C"(acount C is the friends of A). Then, when I click C item to 'Chat Activity can show the message from C.