在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):lyft/Kronos-Android开源软件地址(OpenSource Url):https://github.com/lyft/Kronos-Android开源编程语言(OpenSource Language):Kotlin 71.9%开源软件介绍(OpenSource Introduction):Kronos-AndroidSynchronized Time Android Library Kronos is an open source Network Time Protocol (NTP) synchronization library for providing a trusted clock on the JVM. Unlike the device clock, the time reported by Kronos is unaffected when the local time is changed while your app is running. Instead, Kronos stores accurate time along with a delta between the NTP time and the system uptime. Since uptime increases monotonically, Kronos isn't affected by device time changes.
Accessing IntroductionInclude the following in your build.gradle file: implementation "com.lyft.kronos:kronos-android:$latest_version" Obtain a Kronos clock that is synchronized with NTP servers. class YourApplication : Application() {
lateinit var kronosClock: KronosClock
override fun onCreate() {
super.onCreate()
kronosClock = AndroidClockFactory.createKronosClock(applicationContext)
kronosClock.syncInBackground()
}
} Replace usages of System.currentTimeMillis() with kronosClock.getCurrentTimeMs() If the NTP server cannot be reached or Kronos has not yet been synced, Since it relies on system uptime, Kronos detects and requires a new sync after each reboot. CustomizationKronos comes with a set of reasonable default configurations. You can customize the configuration by using
With or without AndroidFor usage with non-Android modules, Kronos provides access to the Kotlin-only base library called Kronos-Java, which depends on an externally provided local clock and a cache. The Android library simply abstracts away the creation of the clock and cache by extracting the Android system clock from a provided Context and creating its own cache using SharedPreferences. To use Kronos-Java include the following in your build.gradle file: implementation "com.lyft.kronos:kronos-java:$latest_version" Version infromation are listed under releases Looking for Kronos for your iOS application? Check out Kronos for iOS License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论