2011-08-25 58 views
3

我目前正在使用GeoCordinateWatcher提取用於檢索位置的信息,並提供它提供狀態的速度(禁用/就緒/無數據/初始化),但僅此而已。在Windows Phone 7上是否有獲取GPS信號當前強度的方法?

我已經看到了一些應用程序,如RunKeeper有一個GPS信號強度指示器,但我不知道這是否是正確的還是它的基礎上的GeoCordinate

注意的Horizo​​ntalAccuracy屬性是否計算:我已閱讀此鏈接: How to read GPS signal strength in Windows Mobile?

但這是處理WP6.5,我不認爲對WP7有幫助。

回答

5

根據經驗(作爲RunKeeper Windows Phone應用程序的開發人員)的說法,您無法直接訪問GPS信號強度,但可以使用Horizo​​ntalAccuracy顯示相對強度指示器。

我使用Rx Extensions在GeoCoordinateWatcher上提供可觀察的位置流,然後在其上創建可觀察的準確性流,以便我可以訂閱與位置更改分開的準確性更改(而不必檢查和更新每個位置)。


// Extension method. 
     public static IObservable<GeoPositionChangedEventArgs<:GeoCoordinate>> GetPositionChangedEventStream(this GeoCoordinateWatcher watcher) 
     { 
      return Observable.Create<GeoPositionChangedEventArgs<GeoCoordinate>>(observable => 
      { 
       EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>> handler = (s, e) => 
       { 
        observable.OnNext(e); 
       }; 
       watcher.PositionChanged += handler; 
       return() => { watcher.PositionChanged -= handler; }; 
      }); 
     } 

// Usage: 
     var positionStream = this._watcher.GetPositionChangedEventStream(); 
     var accuracyStream = positionStream.Select(p => p.Position.Location.HorizontalAccuracy); 
     ... 
     accuracyStream.Subscribe((accuracy) => 
      { 
       // Do something with the accuracy. 
      }); 
+0

太棒了。 Thanks.Good工作在RunKeeper應用程序也。我一直都在使用它。 –