NativeScript / NativeScript/plugins
Using geolocation in Android Service, Location doesn't update but horizontal + verticalAccuracy increasing
Personne n'a encore pris cette issue.
- Langage dominant
- TypeScript
- Étoiles
- 206
- Forks
- 123
- Merge moyen
- 2 j 1 h
- PR mergées (30 j)
- 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);
},
});
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple Android Service dans l’issue et examinez l’appel getCurrentLocation de @nativescript/geolocation, y compris ses options accuracy, maximumAge et timeout. Reproduisez le comportement avec l’application réduite et comparez les valeurs de localisation successives. Le travail est terminé lorsque le comportement attendu de la localisation en arrière-plan est établi et que l’issue comporte soit un correctif vérifié, soit une limitation de la plateforme documentée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- android, typescript
- Domaine
- mobile-dev
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 28/100