in one of my activity, I am using the FusedLocationProviderClient to get constant location update. My codes are based on this method: https://developer.android.com/training/location/receive-location-updates
In my onCreate, I setup the provider and callbacks
// setup fused location provider
mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
// build location request
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(30000);
mLocationRequest.setFastestInterval(10000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setSmallestDisplacement(50);
// Setup the callback function.
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if (locationResult == null) {
return;
}
for (Location location : locationResult.getLocations()) {
// Update UI with location data
// ...
mCurrentLocation = location;
}
}
};
In onResume
mFusedLocationProviderClient.requestLocationUpdates(mLocationRequest,
mLocationCallback,
Looper.myLooper());
In onPause
mFusedLocationProviderClient.removeLocationUpdates(mLocationCallback);
Yet for some reason, leak canary is still indicating that there's memory leak. Leak canary log shown below
Browsing around stack overflow, there are posts that seems to suggest that the leak is due to google play service. But those post were talking about fusedLocationApi, while I'm using the fusedLocationProviderClient, so I'm not sure if its the same thing as what I am using here. Can some one confirm for me ? Thank you!