Skip to content

Instantly share code, notes, and snippets.

@Felipe00
Last active June 3, 2019 20:24
Show Gist options
  • Save Felipe00/8d2e80ce46b33c35d87eef44cc74a7ef to your computer and use it in GitHub Desktop.
Save Felipe00/8d2e80ce46b33c35d87eef44cc74a7ef to your computer and use it in GitHub Desktop.
dependencies {
// other libs..
// smart Location
implementation('io.nlopez.smartlocation:library:3.3.3') {
transitive = false
}
}
private void startLocation() {
Context mContext = MainActivity.this;
SmartLocation.with(mContext).location().config(LocationParams.NAVIGATION)
.start(new OnLocationUpdatedListener() {
@Override
public void onLocationUpdated(Location location) {
Log.w("Localização", "Lat: " + location.getLatitude() + ",Lng: " + location.getLongitude());
}
});
}
private void stopLocation() {
Context mContext = MainActivity.this;
SmartLocation.with(mContext).location().stop();
}
private void getLocation() {
LocationParams params = new LocationParams.Builder().setInterval(5).setDistance(10).setAccuracy(LocationAccuracy.HIGH).build();
SmartLocation.with(context).location().config(params).continuous().start(new OnLocationUpdatedListener() {
@Override
public void onLocationUpdated(Location location) {
Log.i("GPSLocations",
"Lat: " + location.getLatitude()
+ "\nLng: " + location.getLongitude()
+ "\n Acc: " + location.getAccuracy());
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment