简体   繁体   中英

Offline Message using smack in android

I can able to create small chat application using smack api.how ever,i am unable to receive offline messages by using offlineMessageManager class in smack api.It just throws a nullpointerexception when i supposed to call method getMessageCount in the first line of code that i pasted here.

            DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null,namespace);
            Form extendedInfo = Form.getFormFrom(info);
            if (extendedInfo != null) {
                String value = extendedInfo.getField("number_of_messages").getValues().next();
                return Integer.parseInt(value);
            }
            }

            return 0;

I got the same issue you described.

I got the ASmack project source, and I'm generating my own library.

The fix for this particular issue is to call

ServiceDiscoveryManager manager = new ServiceDiscoveryManager(connection);

after you logged in. Seems they missed to initialize this class at some point.

Let me know if you have other issues after this, I got a ClassCastException, but I can help you if you got it.

-f4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM