I'm developing an application which gets the user location at start. I am using Smart Location Library to fetch the location and reverse geocode. But the main problem is that GPS is connected showing in notification even after application closed. I checked the stack trace but did not found any leaked window exception there. I'm using this code to fetch my location..
private void getMyLocation(){
final long mLocTrackingInterval = 1000000 * 5; // 5 sec
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)
// .continuous()
.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()
method of the Main actvity..
@Override
protected void onStop() {
super.onStop();
SmartLocation.with(mContext).location(provider).stop();
SmartLocation.with(mContext).geocoding().stop();
}
Edit
I'm using this povider. I've tried other providers too. But still the same result.
private LocationGooglePlayServicesWithFallbackProvider provider=new LocationGooglePlayServicesWithFallbackProvider(mContext);
I've tried a lot but am not able to figure out what is the actual problem. Any help would be Appreciated. Thanks