tags:

views:

31

answers:

3

My android app requires to get the current date and time from internet. I can't rely on the date from the phone How is it possible to get the time from internet. what are the available time servers ?

A: 

This should help:

http://en.wikipedia.org/wiki/Network_Time_Protocol

Thorsten Dittmar
A: 

There are a lot of time servers, the one to select would probably depend on where you are in the wold. You can find a list of the "public" ones at the NTP.org. You can get information on how you need to communicate with an NTP server from RFC958. Just an FYI, I think changing the time on the device would require ROOT permissions.

Ryan Conrad
A: 

The simplest is the daytime protocol assigned to port 13, but only few servers offer this (optional in e.g. Windows NT and later). What do you have available to query against?

Thorbjørn Ravn Andersen
could you please detail on the last part "what do you have available to query against?"...To be more clear, i am trying to release a limited period trial pack of my android app. Which will allow the users to use (all the features) my app free for 1 month. Since it is limited, i am hard coding a trial-offer expiry date ( do not confuse this with the 1 month trial. This, trial offer expiry date is the expiry for the apk itself) in my application code before compiling it for release.
Mithraa
So, that users cannot uninstall my app once the trial expires and again reinstall and use it forever. When the app is run for the first time, i compare hardcoded date with date from time server ( I am planning to use time server because of the possibility that the user might tweak the phone timings himself before installing and break my security check ) to validate the apk's expiry.
Mithraa
I have no idea about integrating my android app with the time server. Any other possibility of getting date from any other valid source other than the phone, is also welcome. BTW does google provide such a time server. Please help me.
Mithraa
You may want to start accepting answers to your questions first.
Thorbjørn Ravn Andersen
The best way to ensure that your application is not tampered with by pirates is to put some part of your application elsewhere and do online requests to get answers. A typical location for such code is the Google Application Engine which Google hosts for free until you reach a pretty high limit. In your case, this could simply be a time stamp service, but that would be too easy to hack I think
Thorbjørn Ravn Andersen