KK
kk121/SecureTimer
Android library for getting current time (Not affected by device time)
SecureTimer
SecureTimer gives current time which doesn't depend on system time, thus changing system time will not affect SecureTimer's time. It is offline and needs sync to NTP Server once per device reboot and not always you request for time.
Download
Gradle:
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.kk121:SecureTimer:v1.0'
}Maven:
<dependency>
<groupId>com.github.kk121</groupId>
<artifactId>SecureTimer</artifactId>
<version>v1.0</version>
</dependency>How to use SecureTimer ?
Initialize the SecureTimer in Application class or MainActivity
SecureTimer.with(getApplicationContext()).initialize();
// Optionally you can pass preferred NTP time servers
SecureTimer.with(getApplicationContext()).initialize("2.in.pool.ntp.org", "0.asia.pool.ntp.org");Getting current time
//time in millis
long currentTimeInMillis = SecureTimer.with(MainActivity.this).getCurrentTimeInMillis();
//date
Date date = SecureTimer.with(MainActivity.this).getCurrentDate();