smart-location-lib icon indicating copy to clipboard operation
smart-location-lib copied to clipboard

onLocationUpdated not called in service

Open alexnix opened this issue 8 years ago • 3 comments

I use this library inside a service, the service extends OnLocationUpdatedListener so I am able to request updates like this:

SmartLocation.with(getApplicationContext()).location().config(LocationParams.NAVIGATION).start(this)

The issue is very strange as my code works on some phone but not on other. On those that does not work I am able to tell that the service did indeed start but onLocationUpdated is never called (GPS is on).

alexnix avatar Jan 04 '17 22:01 alexnix

Might that have to do with permission request? I have

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

in my manifest. But as of Android run time permission maybe I need to request it explicitly or something?

alexnix avatar Jan 05 '17 15:01 alexnix

If you make an application for Android Marshmallow and above (api >23) you should request for permissions to the user. See the official docs for learning how to do that.

Gloix avatar Jan 07 '17 18:01 Gloix

It is true. I requested permission before calling the library and it worked!

Would be nice if the library included this check too!

alexnix avatar Jan 08 '17 10:01 alexnix