我正在與phonegap和cordova.js GPS相關的應用程序。我的應用在iOS中工作正常。在android中,每當我關閉GPS並重新啓用它時,應用程序將無法識別GPS服務。我需要關閉並重新打開應用程序或使用location.reload(true)
來引用應用程序。爲什麼它是這樣的。我正在使用下面的代碼段。全球定位系統沒有得到禁用和再次啓用Android PhonePhone
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++;
}