Open danponce opened 7 years ago
@mrmans0n It would be really helpful if you add this option too.. Thanks in advance
+1
That option is provided.
provider = new LocationGooglePlayServicesProvider(); provider.setCheckLocationSettings(true);
@araiyusuke thanks for your suggestion, it shows the dialog indeed. But the location itself is not fetched, the callback is not fired. Here is my code:
SmartLocation
.with(this)
.location(LocationGooglePlayServicesProvider().apply { setCheckLocationSettings(true) })
.start {
Timber.e(it.toString())
}
If GPS is already enabled and it doesn't need to show the dialog, it works normally. Any info on that?
@araiyusuke thanks for your suggestion, it shows the dialog indeed. But the location itself is not fetched, the callback is not fired. Here is my code:
SmartLocation .with(this) .location(LocationGooglePlayServicesProvider().apply { setCheckLocationSettings(true) }) .start { Timber.e(it.toString()) }
If GPS is already enabled and it doesn't need to show the dialog, it works normally. Any info on that?
Hey I was experiencing the same problem, but then found out the solution. It's there in the log, saying that you will get your callback in your Activity's callback. Then you need to call the provider's onActivityResult to continue the flow or probably just start requesting location again.
LocationGooglePlayServicesProvider.this.logger.w("Location settings are not satisfied. Show the user a dialog to upgrade location settings. You should hook into the Activity onActivityResult and call this provider's onActivityResult method for continuing this call flow. ", new Object[0]);
Basically you can not show Location Settings if not init SmartLocation using Activity Context, because the Dialog only show if context is instance of Activity as shown below..
if (context instanceof Activity) { try { // Show the dialog by calling startResolutionForResult(), and check the result // in onActivityResult(). status.startResolutionForResult((Activity) context, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException e) { logger.i("PendingIntent unable to execute request."); } } else { logger.w("Provided context is not the context of an activity, therefore we can't launch the resolution activity."); }
This library is great! It simplifies a lot the code for getting locations, so thanks! Now, to show the dialog (same as the Google Maps dialog) that turns the GPS on, the library needs to use LocationSettingsRequest.Builder and use the method setAlwaysShow(true). Can you add this option please?