Time synchronization for Android via TimeServer
Knowing the precise time is very important in the modern world, where everything can change literally in a matter of minutes. Sometimes just a few seconds can be granted in order to solve the problem. Fortunately, the capability to know the precise time anywhere in the world is not a difficult task. It is enough to have at hand any device with the access to the Internet. Let’s consider how to determine the precise time on smartphones and tablets operating under Android.
About time synchronization
There are various ways to determine the precise time. For ordinary people, the most convenient and easy way is to use time synchronization servers (NTP server). Most operating systems installed on computers and mobile devices have a built-in feature for working with such NTP-servers. The algorithm for synchronizing the device's internal time with time on a remote server is quite simple:
- The user device sends off a request to the synchronization server using a special network protocol — NTP (Network Time Protocol).
- In response to the request, the server generates an NTP packet with the required data and sends it back to the user device.
- The built-in synchronization feature processes the packet and adjusts the internal time of the device using the data from the NTP packet.
- High synchronization precision (up to one hundredth of a second, i.e. 10 milliseconds) is achieved due to the fact that the time setting function takes into account the delay between sending off the request and receiving the NTP-packet from server.
The NTP server itself determines the precise time according to a really (physically) existing time standard. This is a whole complex of equipment which task is to count time. There are several time standards in the world located in technologically advanced countries, including Russia. The atomic clock is available at the All-Russian Scientific Research Institute of Physicotechnical and Radiotechnical Measurements (VNIIFTRI).
Time synchronization with TimeServer on Android
Android operating systems also have a built-in feature of time synchronization via the net. However, users can not configure it. The system checks the time with the NTP server, which, in fact, is unknown to the owner of the Android device. It also remains a secret how exactly the basic time synchronization feature works under Android.
For the time synchronization on smartphones and tablets running under Android there is only one way — the use of special applications. However, here there are some nuances. Android OS prohibits third-party applications to change the date and time settings, which is done for security reasons. In order to let the time synchronization applications work on a full scale, the user needs root-rights. Without the root-rights such programs can not change the system settings in automatic mode; however they can still determine the precise time. In this case, the user will occasionally have to manually set the time on his Android device.
Let's learn how it is done using an example of time synchronization application ClockSync with NTP-server timeserver.ru.
ClockSync with root-rights
Open Google Play on your smartphone or tablet and download the ClockSync application.
Run the application and go to its settings. To access the menu, click the button in the upper right corner of the application.
Go to the "NTP Settings" section.
Type in the address in the "NTP server" field — timeserver.ru and click "OK".
Click the return button on your smartphone to return to the previous page and go to the the main menu again. If the device has the root access, then select "Update" and allow the root access for the application if such a message appears on the screen.
In the "Offset" section, the system time offset will be displayed in comparison with time on the NTP server.
Open the menu again, and select "Synchronize".
If the synchronization is successful, a respective message will be displayed at the bottom of the screen.
To activate the automatic time setting feature, go back to "Settings", and check the "Enable automatic synchronization" box. You can set the synchronization period in the "Interval" section.
ClockSync without root-rights
Follow steps 1 to 6 according to the instructions above. After the server has been set, go to the main page of the application, open the settings menu and select "Synchronize" in it. The program will not be able to automatically change the system time, so the smartphone will open the time and date settings section, and a reverse timer will appear at the bottom of the screen.
First, switch the "Use Internet time" slider to the off position. Then open the "Time" section.
Set the hour (in this case — 16 hours). Then move the "minute hand" to the position indicated in the "Time" section (in this case — 40 minutes).
As soon as the timer reaches "00", press the "OK" button. The current precise time will be saved on your Android device.
This procedure can be performed once a month or more often. The error in synchronization in manual mode is 1 second.