smart-location-lib
smart-location-lib copied to clipboard
Any Sample code for using location update while in DetectedActivity.VEHICLE
- First of all i appreciate the developers behind this Smart Library who made using location as simpler as possible.........
Now coming to the issue / problem now facing: How to use this location updates while walking in my method. please note that i have implemented OnLocationUpdatedListener in the Activity
`
private void startLocation() {
provider = new LocationGooglePlayServicesProvider();
provider.setCheckLocationSettings(true);
SmartLocation smartLocation = new SmartLocation.Builder(this).logging(true).build();
smartLocation.location(new LocationBasedOnActivityProvider(**call back**).config(LocationParams.NAVIGATION).start(this);
}
`
What is this call back.
or can u post a sample code , how to use this location updates while walking or running... etc like that....
Finally got the code:
SmartLocation.with(this).location(new LocationBasedOnActivityProvider(new LocationBasedOnActivityProvider.LocationBasedOnActivityListener() {
@Override
public LocationParams locationParamsForActivity(DetectedActivity detectedActivity) {
if (detectedActivity.getConfidence() >= 75) {
LocationParams.Builder builder = new LocationParams.Builder();
switch (detectedActivity.getType()) {
case DetectedActivity.IN_VEHICLE:
builder.setInterval(/*Interval*/)
.setAccuracy(/*Locaiton Accuracy*/);
break;
case DetectedActivity.ON_BICYCLE:
/* So on and so forth.... */
break;
}
return builder.build();
}
return null;
}
})).start(new OnLocationUpdatedListener() {
@Override
public void onLocationUpdated(Location location) {
//Do what you need here.
}
});