Android devices have two ways to synchronize time. One way is to manually adjust the time. One is to use the time provided by the network.
note:
The source code comes from Android 7. 1.
Second, a detailed introduction
Note: This article focuses on the services related to network synchronization.
1.app terminal
By setting the settings. That is, Global.AUTO_TIME
Settings. Global.putint (mcontext.getcontentresolver (), setting. Global automatic time,
isChecked? 1 : 0);
1 stands for on.
0 means off.
2. System server-network time update service
1) ADB quick query mode
Adb shell dumpsys network _ time _ update _ service
Understand several key variables
Understand the real implementation method
2) Details of business implementation
Knowledge supplement:
Knowledge point one,
DatagramSocket
data clustering
DatagramSocket socket = null
This SNTP protocol for socket communication is also very good.
Knowledge point 2
System.currentTimeMillis
System clock. elapse real-time
Where and how to get the startup time?
Reference learning