【问题标题】:Check GPS state (on/off)in cordova android在cordova android中检查GPS状态(开/关)
【发布时间】:2014-10-28 09:34:37
【问题描述】:

我已成功使用此 (https://github.com/apache/cordova-plugin-geolocation) 为科尔多瓦实施地理定位,但是手机中的 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);

        });

更新

onerrorSONY XPERIA T 中执行,但在其他设备(Micromax、Samsung、Motog)中不执行

【问题讨论】:

    标签: android angularjs cordova gps


    【解决方案1】:

    我不知道这是否是你想要的,但我正在使用这个对我很有效的插件

    https://github.com/mablack/cordova-diagnostic-plugin

    我认为,如果 GPS 处于打开/关闭状态,Geolocation API 不会给您一个错误,如果它无法在您指定的时间限制内获得锁定,则只是一个超时错误,但我不久前对其进行了测试并且我可能弄错了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 2011-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多