Which is the best way to detect if GPS is on or off with phonegap?
I'm using this: https://github.com/BastienL/GPSDetector and works great.
On Android 4.x works all correctly, but on Android 2.x I have a problem:
Seems that the problem is in this row:
gpsDetect = cordova.require('cordova/plugin/gpsDetectionPlugin');
with this error:
02-26 22:54:59.181: E/Web Console(821): module cordova/plugin/gpsDetectionPlugin not found at undefined:0
My code:
//Check GPS On/Off
function checkGPS(){
var gpsDetect = cordova.require('cordova/plugin/gpsDetectionPlugin');
gpsDetect.checkGPS(onGPS, onGPSError);
}
function onGPS(r){
if(!r){
Backbone.history.navigate('/errors/gps/', {trigger: true});
return;
}
return true;
}
function onGPSError(){
Backbone.history.navigate('/errors/gps/', {trigger: true});
return;
}
Any hints/ideas?
Thanks.