NativeScript / NativeScript/plugins

Using geolocation in Android Service, Location doesn't update but horizontal + verticalAccuracy increasing

未關閉
#308 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
TypeScript
星號
206
分支
123
平均合併
2 天 1 小時
30 天內合併 PR
1

描述

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);
  },
});

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中的 Android Service 範例開始,檢查 @nativescript/geolocation 的 getCurrentLocation 呼叫,包括其 accuracy、maximumAge 和 timeout 選項。在應用程式最小化的情況下重現該行為,並比較連續的位置值。完成的標準是確立預期的背景位置行為,且 issue 已有經過驗證的修正或已記錄的平台限制。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
android, typescript
領域
mobile-dev
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
28/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。