Geolocation.watchposition does not work with network location off

I am creating a location app for Android using sencha 2.3.1 + phonegap 3.3.0 and using geolocation to display a list of destinations sorted by proximity to the user's location. Everything works fine if the network location setting is enabled. But if I turn it off and leave gps only based on location, it will never be detected. The code is very simple, I tried and the sencha path:

Ext.device.Geolocation.watchPosition({ frequency: 10000, callback: function(position) { AppHelper.setCurrentLocation(position);//yeah!! }, failure: function() { AppHelper.setLocationModeOff();//oouch! } }); 

and telephone way:

 var success = function(position) { AppHelper.setCurrentLocation(position); }; var fail = function() { AppHelper.setLocationModeOff(); }; navigator.geolocation.watchPosition(success, fail,{ timeout: 30000 }); 

The result is the same, I tried to wait a couple of minutes for geolocation, but no signs of the location service.

A phone card placement plugin is installed, the correct permissions are installed, and everything works if the network location is enabled.

I am testing a Sony Tablet S.

I know about this error: How to get GPS user position in Sencha But I checked the code and it is definitely fixed in sencha 2.3.1

I would try other devices, but I was wondering if anyone had experienced the same thing.

TIA.

EDIT: I did an experiment using the standard html5 code on my Android device using the default browser for the system (based on web kit). I would gain access to my settings page and change the settings every time I start.

Access to http://html5demos.com/geo I get the following:

I started the device with a network connection and a gps shutdown: I get a message that asks if I want to share my location. I say yes, only this time everything is working fine.

Disable network geolocation, gps is still off: Unable to locate. (as was expected)

Turn GPS on, leave network geolocation off: Geolocation fails, I do not receive a request to use my location and the subsequent activation of a GPS-based GPS installation.

So, my conclusion: this is similar to what I noticed in a telephone bundle. If network geolocation works, everything works as expected. But if I don’t have a network connection and gps works, this is pretty useless in my html5 application.

At least this is what happens on my device (sony tablet)

+6
source share
1 answer

From my understanding of the HTML5 geolocation API, this is the expected behavior, you simply cannot control if GPS or network location is used under the hood.

What probably happens is that watchPosition() , when called, first tries to do raw, fast positioning using the network, then comes with gps positioning to give you a better result (if you called it with the enableHighAccuracy parameter).

If you turn off network positioning, it is probably stuck at the first point: as indicated in the cordova / phonegap docs, permission to access a rough location is a requirement for geolocation to work.

 (in app/AndroidManifest.xml) <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

I assume that canceling access to a rough location from the device settings somehow "cancels" the user permissions granted when installing the application.

0
source

All Articles