Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
检查cordova android中的GPS状态(开/关)_Android_Angularjs_Cordova_Gps - Fatal编程技术网

检查cordova android中的GPS状态(开/关)

检查cordova android中的GPS状态(开/关),android,angularjs,cordova,gps,Android,Angularjs,Cordova,Gps,我正在使用此()为cordova成功实施地理定位,但从未调用手机中的gpsonerror功能。是否有其他方法检查gps是否打开。这是我的代码 navigator.geolocation.getCurrentPosition(function (position) { //getting location lat=position.coords.latitude; long=position.coords.longitude; }, function (error) { //w

我正在使用此()为cordova成功实施地理定位,但从未调用手机中的gps
onerror
功能。是否有其他方法检查gps是否打开。这是我的代码

navigator.geolocation.getCurrentPosition(function (position) {
//getting location
 lat=position.coords.latitude;
long=position.coords.longitude;

}, function (error) {
        //when gps is off it is never executed
         alert('Unable to get location: ' + error.message);

        });
更新


onerror
是在索尼XPERIA T中执行的,但不是在其他设备(Micromax、三星、Motog)中执行的

我认为,如果GPS处于打开/关闭状态,地理定位API不会给您错误,如果无法在您指定的时间限制内获得锁定,则只会给您超时错误,但我不久前测试了它,可能弄错了