【发布时间】:2016-12-27 09:59:22
【问题描述】:
我知道 XMPP 中的 XEP-0202 可以获取服务器 UTC 时间,但我不知道如何将它与 Android SMACK 库一起使用来获取应用程序中的服务器时间。
有什么想法吗?
【问题讨论】:
我知道 XMPP 中的 XEP-0202 可以获取服务器 UTC 时间,但我不知道如何将它与 Android SMACK 库一起使用来获取应用程序中的服务器时间。
有什么想法吗?
【问题讨论】:
public void GetServerTime(){
if(xmppConnection!=null&&xmppConnection.isConnected())
try {
EntityTimeManager timeManager = EntityTimeManager.getInstanceFor(xmppConnection);
String time = timeManager.getTime("SERVERDOMAIN").getUtc();
Log.d("",""+time);
}catch (Exception e){
Log.d("",""+e);
}
}
而 SERVERDOMAIN 是您的 xmpp 服务器网址。您添加它以制作用户 JID,即 4435956895@chat.xxmpp.com。
`
chat.xxmpp.com
` 将用作 SERVERDOMAIN
【讨论】: