mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 352 forks source link

Location settings are not satisfied! #252

Closed yavuzkoca closed 5 years ago

yavuzkoca commented 5 years ago

The code that I wrote yesterday was working perfectly but suddenly it started to give this:

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. Provided context is not the context of an activity, therefore we can't launch the resolution activity.

Im almost sure that Im asking and granting requested permissions. Like I said, It was working yesterday. Im using the same code that given in sample using Kotlin Language.

RazibKani commented 5 years ago

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