yayaa / LocationManager

Simplify getting user's location for Android
807 stars 186 forks source link

Duplicate system dialog to enable GPS #115

Closed lavruxa closed 3 years ago

lavruxa commented 4 years ago

Hi, just recently switched lib ver 2.3.0 to 2.4.0 and only added new line .failOnSettingsApiSuspended(true) to GooglePlayServicesConfiguration

Now, when app has GPS permission and GPS is disabled, it shows twice system dialog to enable GPS when I start activity. Before lib update this dialog appeared only once.

If I remove .failOnSettingsApiSuspended(true) , the app will show this dialog 5-6 times in case I tap "NO THANKS".

Configuration

public static LocationConfiguration navigationConfiguration() {

    LocationRequest locationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY).setInterval(4000).setFastestInterval(1000).setSmallestDisplacement(1);

    //google play services configuration
    GooglePlayServicesConfiguration gpsc = new GooglePlayServicesConfiguration.Builder()
            .locationRequest(locationRequest)
            .fallbackToDefault(true)
            .askForGooglePlayServices(true)
            .askForSettingsApi(true)
            .failOnSettingsApiSuspended(true)
            .ignoreLastKnowLocation(false)
            .setWaitPeriod(6000)
            .build();

    return new LocationConfiguration.Builder()
            .keepTracking(true)
            .useGooglePlayServices(gpsc)
            .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                    .requiredDistanceInterval(5)
                    .acceptableAccuracy(1.0f)
                    .requiredTimeInterval(1000)
                    .acceptableTimePeriod(1000)
                    .setWaitPeriod(ProviderType.DEFAULT_PROVIDERS, 6000)
                    .build())
            .build();
}

Logs

I/LocationManager: We got permission! I/DispatcherLocationProvider: GooglePlayServices is available on device. Attempting to get location from Google Play Services providers... I/GooglePlayServicesLocationProvider: Start request location updates. I/GooglePlayServicesLocationProvider: Start request location updates. I/GooglePlayServicesLocationProvider$1: LastKnowLocation is not available. I/GooglePlayServicesLocationProvider: Ask for location update... Asking for SettingsApi... I/GooglePlayServicesLocationProvider$1: LastKnowLocation is not available. I/GooglePlayServicesLocationProvider: Ask for location update... Asking for SettingsApi... I/GooglePlayServicesLocationProvider: We need settingsApi dialog to switch required settings on. Displaying the dialog... I/GooglePlayServicesLocationProvider: We need settingsApi dialog to switch required settings on. Displaying the dialog... I/GooglePlayServicesLocationProvider: User denied settingsApi dialog, GooglePlayServices SettingsApi failing... Canceling GooglePlayServiceLocationProvider... I/GooglePlayServicesLocationProvider: Stop location updates...

LionisIAm commented 3 years ago

Any updates here?

yayaa commented 3 years ago

I have just released the v2.4.1 containing the fix for the issue, please give it a try and feel free to re-open if not resolved.