I am using asmack library for my chat application.I am using below described code for getting messagecount:
ServiceDiscoveryManager manager = ServiceDiscoveryMan
Replace your code with this . I have used this code its running fine.
public int offlinemessagecount(){
try {
ServiceDiscoveryManager manager = ServiceDiscoveryManager
.getInstanceFor(connection);
DiscoverInfo info = manager.discoverInfo(null,
"http://jabber.org/protocol/offline");
Form extendedInfo = Form.getFormFrom(info);
if (extendedInfo != null) {
String value = extendedInfo.getField("number_of_messages")
.getValues().next();
return Integer.parseInt(value);
}
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}