I am sending below request for getting the LastActivity(Last seen status) of the below user from ejabbered server using smack library in android.
try {
Packet pk = new Packet() {
@Override
public String toXML() {
// TODO Auto-generated method stub
return "<iq from='" + Utils.createJabberUserIdByUserId(me.getUserId()) + "'" + " id='last1' "
+ " to='" + Utils.createJabberUserIdByUserId(friendId) + "' " + " type='get'> "
+ "<query xmlns='jabber:iq:last'/>" + "</iq>";
}
};
ConnectionManager.getInstance().getXmppConnection().sendPacket(pk);
} catch (Exception e) {
// TODO: handle exception
}
Result I got from the server is:
<iq from="272@jabber.com">
id="last1"
to="274@jabber.com/64faf3314bee33c4"
type="result"
</iq>
But the result should be like this:
<iq from='272@jabber.com'
id='last1'
to='274@jabber.com/64faf3314bee33c4'
type='result'>
<query xmlns='jabber:iq:last' seconds='903'/>
</iq>
What am I doing wrong? please help.
It is usually a sign that there is no provider for the query
/jabber:iq:last
extension, if you don't get that child XML of an IQ in Smack. You will have to register a Provider with the Provider Manager.
BTW I recommend using the offical aSmack version, where this would been done automatically for your.