I have gone through many similar threads and i could not solve it yet .
Message sent from the Device1 is received in the Device1 but not receiving in Device2 . Following is the code i used ,
// Declaration - globally
private ChatManager chatManager;
private MessageListener messageListener;
org.jivesoftware.smack.Chat chat ;
// Initialization - inside onCreate
chat = chatManager.createChat("cst_meadows1@tpchat.com", messageListener);
chatManager = connection.getChatManager();
messageListener = new MyMessageListener();
// MyMessageListener() method
class MyMessageListener implements MessageListener
{
@Override
public void processMessage(org.jivesoftware.smack.Chat chat, Message message)
{
String body = message.getBody();
System.out.println(String.format("Received message '%1$s'", body));
Log.e("message received", " body - "+body);
chat_body.add(body);
lsadapter.notifyDataSetChanged();
lv.invalidate();
}
}
// to send the message - in button click
chat.sendMessage(text);
but MessageListener is not calling for the incoming messages rather it is called for the messages that are sent from the current device .
I have also tried , xmpp send and receive message in android application
How to receive Incoming XMPP Messages using Smack?
I don't know where i am going wrong . Do i need to give any permission in manifest.xml?