1

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?

Community
  • 1
  • 1
VIGNESH
  • 2,023
  • 8
  • 31
  • 46
  • Had you implement the listener and connection parts? Like @Samik Bandyopadhyay posted in his answer at http://stackoverflow.com/questions/4994759/how-to-receive-incoming-messages-using-smack-lib-on-xmpp – Stan Feb 03 '14 at 11:38
  • does your receiver is your android app or some third party client software like spark.? – Waqar Ahmed Feb 03 '14 at 11:38
  • @Stan : Yes i have tried implementing the listener and connection part – VIGNESH Feb 03 '14 at 11:41
  • Actually its not a point of TRYING to implement, it MUST BE IMPLEMENTED. Connection SHOULD be established otherwise the whole system wont work. It should send data to XMPP server and so other clients shoud receive it. How do you think the magic happens? Data (message) should be delivered via internet to the server and then back to clients. That means both devices should have a connection to Internet as well. – Stan Feb 03 '14 at 11:46
  • @Stan : Yes i have established the connection and i could get the connection id . And both the devices are connected to internet . – VIGNESH Feb 03 '14 at 11:55

0 Answers0