NativeScript / NativeScript/plugins
Using geolocation in Android Service, Location doesn't update but horizontal + verticalAccuracy increasing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 206
- Forks
- 123
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 1
Description
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);
},
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Android Service example in the issue and inspect the @nativescript/geolocation getCurrentLocation call, including its accuracy, maximumAge, and timeout options. Reproduce the behavior with the app minimized and compare successive location values. Done means the expected background location behavior is established and the issue has a verified fix or a documented platform limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100