【发布时间】:2015-07-22 16:50:44
【问题描述】:
我正在 phonegap 和 cordova.js 中使用与 GPS 相关的应用程序。我的应用在 iOS 中运行良好。在 android 中,每当我关闭 gps 并再次启用它时,应用程序将无法识别 GPS 服务。我需要再次关闭并重新打开该应用程序或使用location.reload(true) 引用该应用程序。为什么会这样。我正在使用以下代码段。
refrshWatchPoss = setInterval(function () {
navigator.geolocation.getCurrentPosition(onWatchPositionSuccess, onWatchPositionError, options);
}, 5000);
function onWatchPositionError(err) {
window.plugins.toast.showLongBottom('App is waiting for location service! ', function (a) {
}, function (b) {
})
if (watchpositionErrorCount >= 9) {
messageAlert('Location service is unavailable. If it is unavailable after restarting then go to settings and reset your location services');
$.mobile.loading('show');
navigator.splashscreen.show();
setTimeout(location.reload(true), 2000);
}
watchpositionErrorCount++;
}
【问题讨论】: