I am developing a chat application for Android using asmack. The connection is getting established and I'm able to login also. I've added listener for IQ packets and that is working fine. I have added listener for Presence packets also, here is my code:
PacketTypeFilter presenceFilter=new PacketTypeFilter(Presence.class);
connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Presence presence = (Presence)packet;
Log.d("test1","Presence packet came :From:"+presence.getFrom()+",Packet ID:"+presence.getPacketID()+",Priority:"+presence.getPriority()+",To:"+presence.getTo()
+",Exn:"+presence.toXML());
if (presence.getType() == Presence.Type.available) {
Log.d("test1","User available");
}
else if (presence.getType() == Presence.Type.unavailable) {
Log.d("test1","User not available");
}
}
}, presenceFilter);
My problem is, this listener is never getting called for any incoming Presence packets. It's working for outgoing ones. I can't use Roster for handling presence as our server is using some Intelligent Routing Service for handling user availability. Am I doing anything wrong here? Any input will be helpful.