Closed mahermeg17 closed 7 years ago
In other way, I need to determinate the user location for a best and minimum conditions and respecting the android docs for the location strategies :
Ref for Location Strategies : https://developer.android.com/guide/topics/location/strategies.html
Best regards,
Please see the configuration object, it is already possible to do it.
You can set doNotUseGooglePlayServices
if you don't want to use Google Play Services at all. But it already handled the cases when asking for GooglePlayServices, which you can also specify the behaviour for that.
Fields below specifies that you want to fail when GoogleApi or SettingsApi connection is not possible, you can choose to fail or continue with alternatives.
failOnConnectionSuspended
failOnSettingsApiSuspended
And if you set askForGPServices
false, then library will not ask user to update or manage GooglePlayServices and will ignore GooglePlayServices not being available and continue with default providers.
Thank you for the quick replay. And it's what I figured out after handling different configurations of the LocationConfiguration. The last point I need your help for it is: I disabled the Google Play Services and I turned off the Wifi Connection and there is no cellular SIM into the device. So the location should be provided by the GPS sensor. But I have the fail message "couldn't get location, because network is not accessible" So what's the recommanded configuration to perform only GPS based location ?
Here is what I'm using and getting the mentioned message
` .askForGooglePlayServices(false)
.setMinAccuracy(200.0f)
.setWaitPeriod(ProviderType.GOOGLE_PLAY_SERVICES, 5 * 1000)
.setWaitPeriod(ProviderType.GPS, 30 * 1000)
.setWaitPeriod(ProviderType.NETWORK, 5 * 1000)
.useOnlyGPServices(false)
.askForSettingsApi(false)
.failOnConnectionSuspended(false)
.failOnSettingsApiSuspended(false)
.doNotUseGooglePlayServices(true)
.askForEnableGPS(true)
.setWithinTimePeriod(60 * 1000)
.setTimeInterval(10 * 1000)
.setGPSMessage("Would you mind to turn GPS on?")
.setRationalMessage("Gimme the permission!");
`
the log shows ` DefaultLocationProvider: GPS is already enabled, getting location...
DefaultLocationProvider: LastKnowLocation is not usable. DefaultLocationProvider: Ask for location update... DefaultLocationProvider$4: We waited enough for GPS, switching to Network provider... DefaultLocationProvider: Network is not enabled, calling fail... `
By the configuration;
.setWaitPeriod(ProviderType.GPS, 30 * 1000)
DefaultLocationProvider$4: We waited enough for GPS, switching to Network provider...
Library is waited 30 seconds and switched to network which is disabled and failed immediately after. You can try to increase waiting time period, but i think if you're not able to receive in 30secs. it's most probably either a hardware issue or you're trying inside :) Unfortunately, GPS Provider in Android not so reliable always. That's why i strongly suggest you to use GooglePlayServices if it is possible, because it has a location pool shared between the applications uses it. So even your application in required time cannot retrieve, it might still receive last known location.
OK. In fact I'm developing an App for industrial use. So probably they will not be others applications installed and using GooglePlayServices and more probably GooglePlayServices will not be there. The same for cellular SIM or Internet connexion. That's why the GPS sensor will be the main location provider. All others will be optional.
Thank you again for the help and for the great library.
Hi,
if Google play services is not available on the device, or there is no Internet connexion to update/install it the Location manager fails and can't provide any location from GPS or Network as showed in attached screenshots.
Are there any way to make the use of google play services optional ?
Thanks in advance.