I'm developing an application to track my phone at regular intervals (not only the first time) with navigator.geolocation.getCurrentPosition()
running in an HTML5 page running in a webkit webview running in an android 2.1 application.
I already read responses to the following questions:
Using navigator.geolocation.getCurrentPosition in WebView on Android 2.0+ (PhoneGap related)
Android: Using html5 to determine geolocation in webview with javascript api
Geolocation cannot be load on webview
Android WebView using GeolocationPermissions
I managed to get the position through the javascript method navigator.geolocation.getCurrentPosition()
, even if with a very bad accuracy (1421 meters).
But the real problem is: if I call the getCurrentPosition()
method more than once, it returns me always the same position and always with the same bad accuracy (1421 meters). It seems that one of these 2 cases occurs:
The device does not get the position from the GPS sensor (fine accuracy), but it gets it via AGPS (from the 3g cell) causing the same position and accuracy being returned. The GPS sensor is obviously on, and I've set the right privileges in the manifest file:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" /> <uses-permission android:name="android.permission.ACCESS_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The device got the first position correctly after calling "getCurrentPosition", but the next time this method is called, the position is returned from some "GPS cache" and the position is not really got from the GPS sensor.
Has anyone successfully gotten the position updated at regular interval through the getCurrentPosition()
HTML5 Javascript method?