Esri / quickstart-map-phonegap

ArcGIS JavaScript samples for use with PhoneGap/Cordova
35 stars 37 forks source link

Geolocation silently fails on Android 6+ #20

Open andygup opened 8 years ago

andygup commented 8 years ago

Starting at Android 6.0 (a.k.a Android M), the sample apps in this repo that require geolocation will fail silently even if the AndroidManifest file has all the correct permissions.

If you are doing remote debugging, you may not see any errors in the browser console. Logcat, however, will show the error E/cr_LocationProvider: Caught security exception while registering for location updates from the system. The application does not have sufficient geolocation permissions.

This is happening because of significant security changes at Android 6. Android 6 and above requires that permissions be granted at runtime as compared to installation-time. You can read more about the technical aspects here in the native API docs. Before Android 6 you could simply set up the AndroidManifest then fire and forget because permissions were established when the user installed the app. This is no longer the case.

Instructions for turning on Geolocation in case of Android 6 failure You'll need to follow these steps in order to get geolocation working again:

Resolution

This needs to be documented and a plugin recommended. This may also include adding additional sample(s) to demonstrate working with a security plugin.

el0911 commented 7 years ago

try this too in manifest file