yayaa / LocationManager

Simplify getting user's location for Android
806 stars 187 forks source link

Fetching location every second #64

Closed rahulr4 closed 7 years ago

rahulr4 commented 7 years ago

I have set a custom configuration but location keeps getting updated every second and that too same location.

Configuration

 /**
     * Returns a LocationConfiguration which tights to default definitions with given messages. Since this method is
     * basically created in order to be used in Activities, User needs to be asked for permission and enabling gps.
     */
    public static LocationConfiguration defaultConfiguration(@NonNull String rationalMessage, @NonNull String gpsMessage) {
        return new LocationConfiguration.Builder()

                .askForPermission(new PermissionConfiguration.Builder().rationaleMessage(rationalMessage).build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder().fallbackToDefault(true)
                        .askForGooglePlayServices(false)
                        .askForSettingsApi(true)
                        .failOnConnectionSuspended(true)
                        .failOnSettingsApiSuspended(false)
                        .setWaitPeriod(10 * 1000)
                        .ignoreLastKnowLocation(true).build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .gpsMessage(gpsMessage)
                        .requiredTimeInterval(10 * 1000)
                        .acceptableTimePeriod(10 * 1000)
                        .requiredDistanceInterval(2 * 1000)
                        .setWaitPeriod(ProviderType.GPS, 5 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 5 * 1000).build())
                .keepTracking(true)
                .build();
    }

Logs

PLEASE SHARE YOUR LOGS

08-15 15:19:22.016 15689-15689I/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666 08-15 15:19:23.012 15689-15689/I/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666 08-15 15:19:24.012 15689-15689/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666 08-15 15:19:25.020 15689-15689/Location Changed: Location Changed - 28.45949666666667 : 77.02664166666666

As you can see onLocationChanged is firing at every second. Is this a bug or is there something wrong with my configuration ?

yayaa commented 7 years ago

Could you share more information from your log? So that i can also see from which provider you keep receiving these location updates. If it is DefaultLocationProviders, i see one possible reason why this might happen. I'll look into.

rahulr4 commented 7 years ago

More log in what sense ? This is the configuration which i use. But If i have set time intervals it should send me request after those time intervals right. For now i have to make a service and call it every 5 minutes. This is a hack which i have used

yayaa commented 7 years ago

v2.0.4 is released, please try with that it should be fixed now.

rahulr4 commented 7 years ago

Can you tell me what in which class you have changed ? I have integrated the whole library

yayaa commented 7 years ago

@rahulr4 see the PR -> https://github.com/yayaa/LocationManager/pull/65