We have suggested a workaround and a detailed implementation of the workaround to Amit. You can find the explanation quoted below. Hope this helps!
I can suggest you remove the geolocation plugin (from Project Properties) for Android devices that implement the geolocation in their default browser. When using this workaround you should add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Have in mind that Cordova are removing their plugin code to allow the default browser implementation to surface. For more information regarding this, please take a look at this jira bug
To support older Android devices, that do not provide geolocation implementation in their WebView component, you would have to slightly modify and replace our Cordova geolocation plugin (the source code is located here
). To replace it please disable your geolocation plugin from Project Properties and add the modified one as a Custom Plugin.
Cordova have hardcoded 60000ms for refresh in the following places:
Change them to something like 5000 and it will work as expected. Please take a look at the official Android documentation for choosing the minTime for loctionUpdates:
Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience. If your application is not in the foreground and showing location to the user then your application should avoid using an active provider (such as
), but if you insist then select a minTime of 5 * 60 * 1000 (5 minutes) or greater. If your application is in the foreground and showing location to the user then it is appropriate to select a faster update interval.
The solution in detail
I managed to replace the core Geolocation plugin with the one my colleague has referenced in his post. Here is the exact workflow I followed in order to do this:
1. First, I created a new blank project in AppBuilder;
2. Then, inside its project properties I disabled the core Geolocation plugin;
3. I downloaded the ZIP from here;
4. And added it under the Plugins folder of my project. This is achieved by right clicking on the Plugins folder and then selecting Add > From Archive;
5. Next, I had to change the minTime values for android devices in the sources of the already imported Geolaction plugin. This is needed on two places:
o Inside /src/android/GPSListener.java on line 44 you should find this:
.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0,
Replace the 60000 value to 5000 for example.
o Inside /src/android/CordovaLocationListener.java on line 201 you should find this:
.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10,
Again, replace the 60000 value with the same as above (5000 as in my case).
6. Note, you can do this directly in AppBuilder!
7. In order to test, if the plugin initializes I added the following lines in Index.html:
alert("Geolocation not initialized!!!");
8. I also added the code from your screenshot:
argscheck = require(
utils = require('cordova/utils'),
exec = require('cordova/exec');
9. Finally, I built the app and deployed it on android device. Everything worked as expected on HTC One device.
Icenium is now Telerik AppBuilder
, and is part of the Telerik Platform
. For more information on the new name, and to learn more about the Platform, register for the free online keynote and webinar
on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT)