如何从服务器时间的Andr​​oid? [英] How to get time from server in android?

查看:159
本文介绍了如何从服务器时间的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  有谁知道一个良好的JSON时间服务器?

有任何公开的 JSON XML present在服务器上,我可以解析为当前的时间?我将利用这段时间,我没有使用日历或日期班检查试用版我的应用程序的保质期。我在我的Andr​​oid新。谢谢你。

Is there any public json or xml present on server which I can parse for current time? I shall use this time for checking the expiration Period of Trial version of my app, I am not using Calendar or Date classes. I am new in Android. Thanks.

推荐答案

我知道它不完全是你问什么,但你也可能得到来自网络提供商的时间(手机网络)。

I know its not exactly what you ask but you may also get the time from the network provider (the mobile phone network).

您是否尝试过

LocationManager locMan = (LocationManager) activity.getSystemService(activity.LOCATION_SERVICE);
long time = locMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getTime();

它返回米利斯的时间。

it returns the time in millis.

所以,你不需要互联网连接或JSON解析,XML ...

So you don't need an internet connection or parsing JSON, XML ...

希望这有助于以某种方式,

Hope this helps somehow,

托比亚斯

这篇关于如何从服务器时间的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆