Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add google location dialog #212

Open
danponce opened this issue Aug 27, 2017 · 6 comments
Open

Add google location dialog #212

danponce opened this issue Aug 27, 2017 · 6 comments

Comments

@danponce
Copy link

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?

@saeedjassani
Copy link

@mrmans0n It would be really helpful if you add this option too.. Thanks in advance

@putrabangga
Copy link

+1

@araiyusuke
Copy link

That option is provided.

provider = new LocationGooglePlayServicesProvider();
provider.setCheckLocationSettings(true);

@Ornolfr
Copy link

Ornolfr commented Feb 22, 2018

@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?

@luthfihariz
Copy link

@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]);

@RazibKani
Copy link

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 snippet from
https://github.com/mrmans0n/smart-location-lib/blob/master/library/src/main/java/io/nlopez/smartlocation/location/providers/LocationGooglePlayServicesProvider.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants