繁体   English   中英

在 android 中使用 smack 的离线消息

[英]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贴在这里。

            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;

我遇到了你描述的同样的问题。

我得到了 ASmack 项目源代码,并且正在生成自己的库。

此特定问题的解决方法是调用

ServiceDiscoveryManager manager = new ServiceDiscoveryManager(connection);

登录后。似乎他们错过了在某些时候初始化这个 class。

如果您在此之后还有其他问题,请告诉我,我收到了 ClassCastException,但如果您遇到了,我可以为您提供帮助。

-f4

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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