Created
April 12, 2018 20:28
-
-
Save Felipe00/c72689ea0eb21ebe12e3ca4cf0b18776 to your computer and use it in GitHub Desktop.
Kotlin implementation Locations (SmartLocation lib)
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
| dependencies { | |
| // https://github.com/mrmans0n/smart-location-lib | |
| compile 'io.nlopez.smartlocation:library:3.3.3' | |
| } |
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
| 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