mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 353 forks source link

Leaked IntentReceiver #193

Open leijdekkers opened 7 years ago

leijdekkers commented 7 years ago

Hi

I get this error when i even try to stop listening for location updates.

So i call this in my code assuming it would stop the smartlocation altogether.

What am i supposed to do to really stop listening for location updates?

// Stop listening
 mSmartLocation.location(mLocationProvider).stop();
 mLocationProvider.stop();

/// Error Activity com.xxxxxx.AuditActivity has leaked IntentReceiver io.nlopez.smartlocation.geocoding.providers.AndroidGeocodingProvider$2@885af5 that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity com.ecsustainable.lsa.audit.AuditActivity has leaked IntentReceiver io.nlopez.smartlocation.geocoding.providers.AndroidGeocodingProvider$2@885af5 that was originally registered here. Are you missing a call to unregisterReceiver()?

krazykira commented 6 years ago

+1 I am also facing this same warning and all i am doing is


   SmartLocation.with(getContext()).geocoding().reverse(userLocation, new OnReverseGeocodingListener() {
            @Override
            public void onAddressResolved(Location location, List<Address> list) {

            }
        });

And When i end the app while gps was turned off then the warning i am getting in log is

Activity com.app.ui.navigation.NavDrawerActivity has leaked IntentReceiver io.nlopez.smartlocation.geocoding.providers.AndroidGeocodingProvider$2@f4ff014 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.app.ui.navigation.NavDrawerActivity has leaked IntentReceiver io.nlopez.smartlocation.geocoding.providers.AndroidGeocodingProvider$2@f4ff014 that was originally registered here. Are you missing a call to unregisterReceiver()?

@mrmans0n Can you please let me know how i can fix this ?

As a workaround i am able to fix it by calling

SmartLocation.with(getContext()).geocoding().stop(); explicitly on Activity onDestroy()

krazykira commented 6 years ago

In #91 @mrmans0n explain that this is by design so we need to call SmartLocation.with(getContext()).geocoding().stop(); explicitly on Activity or Fragment onDestroy()