Skip to content

How to use this library

Kaushik Gopal edited this page Feb 25, 2023 · 5 revisions

Installation

We use JitPack to host the library.

Add this to your application's build.gradle file:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    // ...
    implementation 'com.github.instacart:truetime-android:<release-version>'
}

Usage

In your application class start the TrueTime sync-er like so:

// App.kt
class App : Application() {

    val trueTime = TrueTimeImpl()

    override fun onCreate() {
        super.onCreate()
        trueTime.sync()
    }
}

Once TrueTime gets a fix with an NTP time server, you can simply use:

(application as App).trueTime.now()

Btw don't do ↑, inject TrueTime into your app and then just call trueTime.now()

Clone this wiki locally