简体   繁体   中英

How to get server time in XMPP SMACK library

I know XEP-0202 in XMPP to get server utc time but I don't know how to use it with Android SMACK library to fetch server time in application.

Any idea ?

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);
            }


    }

while SERVERDOMAIN is your xmpp server url. which you add to make User JID ie 4435956895@chat.xxmpp.com .

`

chat.xxmpp.com

` will be use as SERVERDOMAIN

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