I am using asmack library for my chat application.I am using below described code for getting messagecount:
ServiceDiscoveryManager manager = ServiceDiscoveryMan
After Googling and searching in documentation,All i got that offlinemanager for getting offline messages.
But However it is not working in asmack or may be in smack.It always return 0 message.
Finally by seeing logs i found that each tie when i login i got lot of response from chat server which also contains offline message but with message tag not offline message tag.So I found finally
You can get offline messages from it by directly setting packet listener after just login .As i below described packet listener you have to implement after login method.
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
this.connection.addPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message
.getFrom());
Log.i("XMPPClient", "Got text [" + message.getBody()
+ "] from [" + fromName + "]");
if (fromName.equalsIgnoreCase(matchUserJabberId
+ "server name")) {
// }
}
}
}
}, filter);
Hope it will help many to find a work around for offline message early as i invested more time to get it out.