AnsweredAssumed Answered

EmbeddedExtensionProvider: How to parse custom stanza

Question asked by Amitoj on Aug 21, 2016
Latest reply on May 6, 2019 by Nischal Manandhar

A part of a new proposed extension, I receive a custom stanza from Ejabberd.


<message to='' from=''>
    <event xmlns=''>
        <items node='urn:xmpp:mucsub:nodes:messages'>
            <item id='15596740304331624371'>
                <message xmlns='jabber:client' from='' to='' type='groupchat' lang='en'>
                    <body xmlns='jabber:client'>{&quot;body&quot;: &quot;Your speech was successfully submitted. You have earned 100 Gappi Points1471755183&quot;, &quot;sender&quot;: &quot;;, &quot;messageCount&quot;: 0, &quot;isMine&quot;: false, &quot;sentSuccess&quot;: 1, &quot;msgid&quot;: 0, &quot;senderid&quot;: &quot;;, &quot;stanzaId&quot;: &quot;pubsubmessage-0f113ee289c241e2996fe0aab78f1485-2016-08-21 04:53&quot;, &quot;receiver&quot;: &quot;;, &quot;date&quot;: &quot;2016-08-21 04:53&quot;, &quot;type&quot;: 1}</body>
    <delay xmlns='urn:xmpp:delay' stamp='2016-08-21T04:53:03.597+00:00' from=''>Offline Storage</delay>


I'm mainly interested in getting the 'inner' message element, that is child of "item" element. This stanza is very similar to one mentioned in the EmbeddedExtensionProvider documentation EmbeddedExtensionProvider (Smack 4.1.8 API) . But I'm not very clear on the exact steps to follow to retrieve the inner message.


I've tried something like this until now.


private class MMessageListener implements ChatMessageListener {

        public MMessageListener(Context context) {




        public void processMessage(final chat,

                                   final Message message) {

            Log.i(TAG, "Xmpp message received:"+ message);

            //Possibly a pubsub offline message

            EventElement eventElement = message.getExtension("event","");

            if(eventElement != null) {

                Log.i(TAG, "EventElement:" + eventElement.getEvent());

                List<ExtensionElement> itemExtensions = eventElement.getExtensions();

                for(int i = 0;i < itemExtensions.size(); i++) {

                    ItemsExtension itemsExtension = (ItemsExtension) itemExtensions.get(i);

                    Log.i(TAG, "ItemExtension:" + itemExtensions.getClass());

                    List<Item> items = (List<Item>)itemsExtension.getItems();

                    for(int j=0; j<items.size(); j++){

                        PayloadItem it = (PayloadItem)items.get(j);

                        SimplePayload payloadElement = (SimplePayload) it.getPayload();







How do I convert this "SimplePayload" element to a proper "Message" object.