speed
value is always null
in Android 5+. We use these:
We get this problem now after we updated to Android 5+.
Still works fine on Android 4 and iOS though. We tried both getCurrentPosition
and watchPosition
– no luck. HighAccuracy
is true
.
We had to implement workaround for Android 5 using getCurrentPosition
(instead of perfectly working watchPosition
for other OSes), which in many times results in calculating speed for some intervals as up to 400 km/h, while calculating more or less accurate speed overall.
We’d like to use one code for all platforms as it should be, and keep using watchPosition
as it works good.
On a related note: Are there any known bugs/issues for Cordova with Galaxy devices in general? Thanks!
navigator.geolocation.getCurrentPosition()
is only check for GPS when option enableHighAccuracy
is set as true
(default).
You could set enableHighAccuracy
as false
.
{enableHighAccuracy:false,maximumAge:Infinity, timeout:60000}
You may need following permissions
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
Hope it helps.
Cordova doesn't provide any native code for the geolocation, it just add the permissions to activate the webview geolocation, so if something doesn't work it's the problem is on the chromium implementation.
You can try to use crosswalk plugin to see if geolocation works better there (it adds an updated chromium webview to your project), or use the version 0.3.6 of the plugin, as that was the latest release with native code.
EDIT: there was an error when passing the params from cordova to the webview geolocation that might cause your issue to, try with latest version of the plugin
cordova plugin add https://github.com/apache/cordova-plugin-geolocation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With