I am developing an application that launches a user's location. I use Smart Location Library to get location and reverse geocode. But the main problem is that the GPS is connected, showing a notification, even after closing the application. I checked the stack trace, but there was no exception detected from the window. I use this code to get my location.
private void getMyLocation(){
final long mLocTrackingInterval = 1000000 * 5;
float trackingDistance = 1000 * 10;
LocationAccuracy trackingAccuracy = LocationAccuracy.HIGH;
LocationParams.Builder builder = new LocationParams.Builder()
.setAccuracy(trackingAccuracy)
.setDistance(trackingDistance)
.setInterval(mLocTrackingInterval);
SmartLocation.with(mContext)
.location(provider)
.oneFix()
.config(builder.build())
.start(this);
}
@Override
public void onLocationUpdated(Location location) {
SmartLocation.with(mContext).geocoding()
.reverse(location,new OnReverseGeocodingListener() {
@Override
public void onAddressResolved(Location location, List<Address> results) {
if (results.size() > 0) {
mAddressList=results;
mLocation=location;
tvLocation.setText( results.get(0).getAddressLine(0)+"\n"+results.get(0).getAddressLine(1));
}
}
});
}
And onStop()the main activity method.
@Override
protected void onStop() {
super.onStop();
SmartLocation.with(mContext).location(provider).stop();
SmartLocation.with(mContext).geocoding().stop();
}
Edit
I am using this povider. I also tried other providers. But all the same result.
private LocationGooglePlayServicesWithFallbackProvider provider=new LocationGooglePlayServicesWithFallbackProvider(mContext);
I tried a lot, but I can not understand what the problem is. Any help would be appreciated. thank