Skip to content

Instantly share code, notes, and snippets.

@Felipe00
Created April 12, 2018 20:28
Show Gist options
  • Select an option

  • Save Felipe00/c72689ea0eb21ebe12e3ca4cf0b18776 to your computer and use it in GitHub Desktop.

Select an option

Save Felipe00/c72689ea0eb21ebe12e3ca4cf0b18776 to your computer and use it in GitHub Desktop.
Kotlin implementation Locations (SmartLocation lib)
dependencies {
// https://github.com/mrmans0n/smart-location-lib
compile 'io.nlopez.smartlocation:library:3.3.3'
}
class MainActivity: AppCompat {
fun startGeoUpdates(callback: (Location) -> Unit) {
val params = LocationParams.Builder().setInterval(5).setDistance(10f).setAccuracy(LocationAccuracy.HIGH).build()
SmartLocation.with(context).location().config(params).continuous().start { location ->
if (location != null) callback(location)
}
}
fun seuMetodo() {
// ...
startGeoUpdates {
Log.i("GPSLocations",
"Lat: " + it.getLatitude()
+ "\nLng: " + it.getLongitude()
+ "\n Acc: " + it.getAccuracy())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment