in my Cordova application, I am trying to get user's location from GPS. For that I am using Geolocation plugin. I need to get location after every 10 seconds. I am doing something like:
navigator.geolocation.getCurrentPosition(
$rootScope.onSuccessForLocation,
$rootScope.onErrorForLocation_High,
{maximumAge:600000, timeout:7000, enableHighAccuracy: true}
);
Now when this code runs, it gives me location in callback method but its not coming from GPS as when app starts the GPS icon should appear and starts blinking in status bar. But it is not happening. I had an old app which is using same plugin. When I start that app, GPS icon starts blinking. One thing that I have noted so far is that in old app, I can see the Geolocation.java file in android project but there is no such file in latest plugin anymore even I tried to search it in the Github source folders. Now, I don't know what is missing on my side. Does anyone have idea what is happening?
They are using HTML5 geolocation implementation instead of native code. They removed the android java code on release 0.3.7 of the plugin
### 0.3.7 (Apr 17, 2014)
* CB-6422: [windows8] use cordova/exec/proxy
* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
* CB-5977: [android] Removing the Android Geolocation Code. Mission Accomplished.
* CB-6460: Update license headers
* Add NOTICE file
If you want to use an older version of the plugin where the native code was used you can install it like this
cordova plugin add org.apache.cordova.geolocation@0.3.6
来源:https://stackoverflow.com/questions/29646690/cordova-geolocation-plugin-not-getting-location-from-gps-for-android