Created
January 6, 2019 13:16
-
-
Save mizutori/77ed33d9f28f2c686da04cc209e69a4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressLint("NewApi") | |
private fun getLocationAge(newLocation: Location): Long { | |
val locationAge: Long | |
if (android.os.Build.VERSION.SDK_INT >= 17) { | |
val currentTimeInMilli = SystemClock.elapsedRealtimeNanos() / 1000000 | |
val locationTimeInMilli = newLocation.elapsedRealtimeNanos / 1000000 | |
locationAge = currentTimeInMilli - locationTimeInMilli | |
} else { | |
locationAge = System.currentTimeMillis() - newLocation.time | |
} | |
return locationAge | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment