0
votes

This is stanza that create from api :

<message xmlns="jabber:client" to="[email protected]/84947029xxx52245593xxx" from="[email protected]">
    <x xmlns="jabber:x:conference" reason="new group chat : mucduke" jid="[email protected]"></x>
    <body>new group chat : mucduke</body>
</message>

I use connection.addAsyncStanzaListener(stanzaListener, stanzaFilter) in android to get the stanza but atribute 'reason' and body element if missing from stanza. Can anyone help me why this happen?

1

1 Answers

1
votes

use following StanzaTypeFilter for add addSyncStanzaListener

 StanzaTypeFilter filter = new StanzaTypeFilter(Message.class);

    mStanzaListener = new StanzaListener() {
        @Override
        public void processPacket(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
                onMessageReceived(stanza);
        }
    };
    connection.addSyncStanzaListener(mStanzaListener, filter);

get stanza onMessageReceived

public void onMessageReceived(Stanza stanza) {

  if(stanza instanceof Message){
      Message msg= (Message) stanza;
      msg.getBody();
      ...
      ...
      }
  }