Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7914227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:02:45+00:00 2026-06-03T14:02:45+00:00

Ok guys, simple question but pretty important to me. so, other android client are

  • 0

Ok guys, simple question but pretty important to me.

so, other android client are sending this xml msg:

<message
  id='6ymdM-19'
  to='xox@xox.xox/smack'
  type='chat'>
  <subject>normal</subject>
  <received xmlns='urn:xmpp:receipts' id='HVgQw-5'/>
</message>

and my listener is roughly like this:

private class MsgListener implements ChatStateListener {
/**
 * Constructor.
 */
public MsgListener() {
}

@Override
public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) {
    String xmlMessage = message.toXML();
    Log.v(TAG, "XML Chat: "+xmlMessage);
    // getExtension namespace try urn:xmpp:receipts
    if(xmlMessage.contains("<request xmlns=")) {
        Log.d(TAG, "new chat message arrive! reply with RECEIVED!");
        replyReceived(message);
    } else if(xmlMessage.contains("<received xmlns=")) {
        Log.d(TAG, "RECEIVED notification arrived!");
        PacketExtension statusExtension = 
                message.getExtension("urn:xmpp:receipts");
        Log.d(TAG, "Extension name: "+statusExtension.getElementName());
        Log.d(TAG, "Extension XML: "+statusExtension.toXML());
        Log.d(TAG, "Extension string: "+statusExtension.toString());
    }

     ....
     ....
     ....
} 

in this case I want to get the value of attribute “id”, inside the “received” element tag.
but what I got on my Log is like this:

RECEIVED notification arrived!
D/ChatAdapter(320): Extension name: received
D/ChatAdapter(320): Extension XML: <received xmlns="urn:xmpp:receipts"></received>
D/ChatAdapter(320): Extension string:              
org.jivesoftware.smack.packet.DefaultPacketExtension@44f10430

So how I can get the ‘HVgQw-5’ ??

UPDATE

Actually there’s something weird…
I have receive the xml accordinh from my SMACK debug like this:

 <
 D/SMACK(320): 05:40:28 PM RCV  (1156991856): message id="6ymdM-19"  
 to="syeikh@emass.sangkuriang.co.id/Smack" from="emu22@emass.sangkuriang.co.id/Smack"  
 type="chat"><subject>
 D/SMACK(320): 05:40:28 PM RCV  (1156991856): normal</subject><thread>cr0900</thread>
 **<received xmlns="urn:xmpp:receipts" id="HVgQw-5"/>**<active      
 xmlns="http://jabber.org/protoc
 D/SMACK(320): 05:40:28 PM RCV  (1156991856): ol/chatstates"/></message>

But when I execute message.toXML it’s just print out like this:

XML Chat: <message id="6ymdM-19" to="syeikh@emass.sangkuriang.co.id/Smack" from="emu22@emass.sangkuriang.co.id/Smack" type="chat"><subject>normal</subject><thread>cr0900</thread>**<received xmlns="urn:xmpp:receipts">**</received><active xmlns="http://jabber.org/protocol/chatstates" /></message>

Why this is happening? why do I miss the “id” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:02:48+00:00Added an answer on June 3, 2026 at 2:02 pm

    About the ID, first get a handle on extension then look for ID, so

    DeliveryReceipt deliveryReceiptObj =(DeliveryReceipt) message.getExtension(DeliveryReceipt.NAMESPACE);
    // ID below is what you want
    deliveryReceiptObj.getId();
    

    Related discussion:
    asmack – receiving custom XML messages

    1. define your EmbeddedPacketExtension ( so you get a handle on this instead of DefaultPacketExtension provided by SMACK )

    2. A provider that extends EmbeddedExtensionProvider

    3. registerProvider you just created with Namespace

    code follows:

    /**
    * User: suvrat 
    * Represents a <b>message delivery receipt</b> entry as specified by
    * <a href="http://xmpp.org/extensions/xep-0184.html">Message Delivery Receipts</a>.
    *
    */
    
    import org.jivesoftware.smack.packet.PacketExtension;
    
    public class DeliveryReceipt implements PacketExtension
    {
    
        public static final String NAMESPACE = "urn:xmpp:receipts";
    
        private String id; /// original ID of the delivered message
    
        public DeliveryReceipt(String id)
        {
            this.id = id;
        }
    
        public String getId()
        {
            return id;
        }
    
        public String getElementName()
        {
            return "received";
        }
    
        public String getNamespace()
        {
            return NAMESPACE;
        }
    
        public String toXML()
        {
            return "<received xmlns='" + NAMESPACE + "' id='" + id + "'/>";
        }
    }
    
     /**
     * User: suvrat
     * The DeliveryReceiptProvider parses DeliveryReceipt packets.
     */
    
     */
    import org.jivesoftware.smack.packet.PacketExtension;
    import org.jivesoftware.smackx.provider.EmbeddedExtensionProvider;
    import org.xmlpull.v1.XmlPullParser;
    
    import java.util.List;
    import java.util.Map;
    
    public class DeliveryReceiptProvider extends EmbeddedExtensionProvider
    {
    
        @Override
        protected PacketExtension createReturnExtension(String currentElement, String currentNamespace,
        Map<String, String> attributeMap, List<? extends PacketExtension> content)
        {
            return new DeliveryReceipt(attributeMap.get("id"));
        }
    
    }
    
       //3.) finally where ever you would like to parse packet
     ProviderManager.getInstance().addExtensionProvider("received", DeliveryReceipt.NAMESPACE, new DeliveryReceiptProvider());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sure this is a simple question for you guys but I don't
I know that this is a simple question for PHP guys but I don't
Hey guys, sorry for this probably fairly simple question but I'm starting to get
This may be a simple question for those know-how guys. But I cannot figure
Well guys, to ask the question is pretty simple, but myself, I'm having a
Hey guys. This is a very simple question, I'm sure, but I'm getting myself
Hey guys I have what should be a simple question, but I am new
Hey guys, this is simple but I can't make it workn... blah! I have
I believe this is a fairly simple question but I have no idea where
Hey guys, I've got what I imagine is a simple question, but for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.