Speed ​​"null" with geolocation plugin on Android 5+

speed The value is always null in Android 5+. We use the following:

  • Core: Cordoba - 5.1.1
  • Platform: Cordova-Android 4.0.2
  • Plugin Version: 1.0.1
  • Devices: Samsung Galaxy S4 (A5.0.1), Nexus 5 (A5.1.1), LG G3 Stylus D690 (A5.0.2).

We get this problem now after we updated Android 5+.

Still works great on Android 4 and iOS. We tried both getCurrentPosition and watchPosition - no luck. HighAccuracy - true .

We had to implement a workaround for Android 5 using getCurrentPosition (instead of the perfectly working watchPosition for other OSs), which in many cases leads to the calculation of speed at some intervals up to 400 km / h, while calculating more or less accurate speed in general.

  • Are there any permissions for Android 5 that we don’t see?
  • What can we do to solve this problem?

Wed likes to use one code for all platforms, as it should be, and continue to use watchPosition as it works well.

  • Any suggestions? Is this a known issue?

Regarding the note: Are there any known bugs / issues for Cordoba with Galaxy devices in general? Thanks!

+8
android cordova geolocation cordova-plugins phonegap-plugins
source share
2 answers

navigator.geolocation.getCurrentPosition() only checks GPS if enableHighAccuracy set to true (default). You can set enableHighAccuracy as false .

 {enableHighAccuracy:false,maximumAge:Infinity, timeout:60000} 

You may need the 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 this helps.

+2
source share

Cordoba does not provide any native code for geolocation, it just adds permissions to activate webview geolocation, so if something does not work, the problem is the implementation of chrome.

You can try using the crosswalk plugin to find out if geolocation works there (adds an updated chrome webview to your project) or uses version 0.3.6 of the plugin since it was the latest version with native code.

EDIT: An error occurred while passing parameters from cordova to webview geolocation, which may cause your problem, try with the latest version of the plugin

 cordova plugin add https://github.com/apache/cordova-plugin-geolocation 
+1
source share

All Articles