mrmans0n / smart-location-lib

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

Change LocationProvider on fly #239

Open jidesoft opened 6 years ago

jidesoft commented 6 years ago

In my app, I need to change the location provider on fly by calling location(...) method. However I noticed it works the first time but never again. Then I found the code below which prevents me from changing the provider. Since the smartLocation.context is the same, it always gets the first location provider it was ever set. Any reason for the code below?

          if (!MAPPING.containsKey(smartLocation.context)) {
                MAPPING.put(smartLocation.context, locationProvider);
            }

            this.provider = (LocationProvider)MAPPING.get(smartLocation.context);