On Windows Phone 7 is there a way of getting the current strength of the GPS signal?
I'm currently using the GeoCordinateWatcher which abstracts away the information used to retrieve the position and speed it provides a status (disabled/ready/nodata/initializing) but that's all.
I've seen a few apps such as RunKeeper that have a GPS signal strength indicator but I wasn't sure whether that was accurate or whether it was calculated based on the HorizontalAccuracy property of the GeoCordinate
NOTE: I have read this link: How to read GPS signal strength in Windows Mobile?
But this is dealing with WP6.开发者_如何学Go5 and I don't think helps on WP7.
Speaking from experience (as the developer of the RunKeeper Windows Phone app), you can't access the GPS signal strength directly, but you can use the HorizontalAccuracy to display a relative strength indicator.
I use Rx Extensions to provide an observable position stream on the GeoCoordinateWatcher, then create an observable accuracy stream on top of that, so that I can subscribe to accuracy changes separate from position changes (rather than having to check and update on every position).
// 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.
});
精彩评论