0

I need some code to be executed only on a certain date. If I get the date from the system the user can cheat by changing the date in the settings. How can I get the current date from the network to avoid that?

EDIT Usage I need:

Btn.setOnClickListener(new View.OnClickListener() { 
public void onClick(View v) {
vib.vibrate(50); 
if (*DATE IS 10.12*){
my method()
}else 
showDialog() 
});
Droidman
  • 11,485
  • 17
  • 93
  • 141

1 Answers1

-1

Try hitting this webservice http://json-time.appspot.com/time.json?tz=GMT

The response is in jason something like this

{

"tz": "GMT",

"hour": 9,

"datetime": "Thu, 06 Dec 2012 09:22:06 +0000",

"second": 6,

"error": false,

"minute": 22

}

Just replace your timezome in the mentioned url.

After getting the response in JSON parse it and get the current date from the response.

So the answer is in two fold:

1)Make a HTTP get request and hit the url with your time zone.

2)Parse the response and fetch the current date and time

I hope this is of some help

curious
  • 371
  • 1
  • 9