plugins
plugins copied to clipboard
Using geolocation in Android Service, Location doesn't update but horizontal + verticalAccuracy increasing
Happening on Android.
I have an example of using an android service. I wish to get the location when the app is minimised. Which the service itself is now working. However when i console log the location. The lng+lat is staying the same, but the horizontalAccuracy & verticalAccuracy is slowly increasing.
I have set the permissions to always allow for location.
export const CONTINUOUS_SERVICE_CLASSNAME =
"bundle";
import { CoreTypes } from "@nativescript/core";
const geolocation = require("@nativescript/geolocation");
android.app.Service.extend("bundle", {
onBind() {
return null;
},
onCreate() {
super.onCreate();
console.log("SERVICE CREATED");
if (!this.timerId) {
this.timerId = setInterval(async () => {
// console.log("PING");
let loc = await geolocation.getCurrentLocation({
desiredAccuracy: CoreTypes.Accuracy.HIGH,
maximumAge: 5000,
timeout: 20000,
});
console.log(loc);
}, 3000);
}
},
onStartCommand(intent, flags, startId) {
console.log("SERVICE STARTED");
return android.app.Service.START_REDELIVER_INTENT;
},
onDestroy() {
console.log("SERVICE DESTROYED");
super.onDestroy();
clearInterval(this.timerId);
},
});