0

特定の日付にのみ実行するコードが必要です。システムから日付を取得すると、ユーザーは設定で日付を変更することでごまかすことができます。それを避けるためにネットワークから現在の日付を取得するにはどうすればよいですか?

私が必要とする編集の使用法:

Btn.setOnClickListener(new View.OnClickListener() { 
public void onClick(View v) {
vib.vibrate(50); 
if (*DATE IS 10.12*){
my method()
}else 
showDialog() 
});
4

1 に答える 1

-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

于 2012-12-06T09:05:42.297 に答える