怎么我的应用程序告诉我们,如果当前日期是真正的当前日期? [英] How does my app tell if the current date is the real current date?

查看:98
本文介绍了怎么我的应用程序告诉我们,如果当前日期是真正的当前日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是创建一个版本的应用程序在某一日期过后,将到期。我想时间处于绝对到期日期,而不是​​相对日期,

My goal is to create a version of the app that will expire after a certain date has passed. I want the time to expire at an absolute date, not a relative date,

因此​​,我的应用程序使用用途此code来检查当前时间:

Hence my app uses uses this code to check the current time:

Calendar nowCalendar = Calendar.getInstance();

但是,用户可以通过改变它们的日期和放大器操纵此;时间设定。

However, the user can manipulate this by changing their Date & Time settings.

问题:
怎么我的应用程序告诉用户是否操纵其日期时间?
要么
如何判断用户是否设置自动日期时间设置?

Question: How does my app tell if the user has manipulated their Date Time? or How do I tell if the user has set the "automatic" Date Time setting?

您能否提供上网查当前时间的最简单的方法?

Can you suggest the simplest way to check the internet for the current time?

推荐答案

每次的程序是启动或退出保存当前的日期时间。如果在下一次系统日期较早的价值,那么你知道的时候已经被篡改。

Each time your app is starts or exits save the current datetime. If next time the system date is an earlier value then you know the time has been tampered with.

您不能有一个完美的解决方案,只有当你有互联网连接。如果你这样做,那么有100万方法可以ckeck的时间,甚至打电话回您的服务器来检查试用许可证是否仍然有效。

You can't have a perfect solution, only if you have internet access. If you do, then there are a million ways you can ckeck for the time, or even call back to your server to check whether the trial license is still valid.

检查互联网时间的一种方式是使一个简单的请求到HTTP服务器。例如谷歌(你应该使用这个自己的服务器)。

One way to check for internet time is making a simple request to an HTTP server. For example to google (you should use your own server for this).

请求:

HEAD / HTTP/1.1
Host: google.com

响应:

HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 09 Mar 2011 16:04:48 GMT
Expires: Fri, 08 Apr 2011 16:04:48 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block

正如你可以看到所有的HTTP服务器报到的%1日期当前系统日期头。

不过话又说回来,这个无所谓的。如果Internet连接是必不可少的软件工作,你可以在自己的服务器上使用网上许可证检查。如果没有,那么用户在使用它可以将其连接了一个按钮的推动。

But then again, this does not matter at all. If Internet connection is essential for your software to work you can use online license check on your own server. If not, then users can turn their connection off with the push of a button while using it.

这篇关于怎么我的应用程序告诉我们,如果当前日期是真正的当前日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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