yayaa / LocationManager

Simplify getting user's location for Android
807 stars 187 forks source link

Needs to fail/warn when permissions aren't defined below Android 6.0 #21

Closed ncapdevi closed 7 years ago

ncapdevi commented 7 years ago

Had an issue where ACCESS_FINE_LOCATION was enabled, and Android devices above 6.0 were able to ask for permissions and work correctly, but below Android 6.0, it would step in and ask for permissions, but try to use ACCESS_COARSE_LOCATION and silently fail with not feedback from the library.

yayaa commented 7 years ago

Did you changed "requiredPermissions" to ask only for ACCESS_FINE_LOCATION? Can you share your configuration please?

And how did you get asked for permissions below 6.0?

ncapdevi commented 7 years ago

Configuration

        mLocationManager =new LocationManager(new LocationConfiguration()
                .askForSettingsApi(true)
                .askForGooglePlayServices(true)
                .askForEnableGPS(true)
                .setMinAccuracy(500f)
                .setWithinTimePeriod(3*60*1000)
                .setRationalMessage("We need your location")).on(getActivity()).notify(mLocationReceiver);

My manifest.xml accidentally only had <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> and not <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

So on a device using 5.0, after a get() is called, none of the callbacks occur after.

yayaa commented 7 years ago

Ahhh, get your point. So below Marshmallow, do the check for required permissions defined in Manifest or not? Yes, good touch! Thanks, will do it :)

ncapdevi commented 7 years ago

Yup! That should take care of it. Thanks for the great work.

yayaa commented 7 years ago

I'll keep this open until i actually implement it, so that i'd not just forget it. Thanks for pointing out this :)

yayaa commented 7 years ago

Hey @ncapdevi Can you elaborate the issue a bit more? I cannot reproduce this one.

Because i tried with API Level 22, and when i don't put any of COARSE or FINE locations in manifest, library immediately fails with "Permissions are denied".