1

I want to ask you, if I understand it. When I create GeoCoordinateWathcer in method OnInvoke of BackgroundAgent like this:

protected override void OnInvoke(ScheduledTask task)
{
    _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                   {
                       MovementThreshold = 100
                   };
    _watcher.PositionChanged += PositionChanged;
    _watcher.Start();
}

and I move more than 100m and Task will be invoked, so PositionChanged doesn't remember my previous position. Is it truth? Then PositionChanged event has no sense in BackgroundAgent, or? If I want to upgrade my position every 100m I have to save previous position and calculate distance with for example Haversine formula from previous and current positions? Thanks man.

MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
Pupino
  • 81
  • 8
  • Possible duplicate of [How does GeoCoordinateWatcher.PositionChaged event work inside a periodic task?](http://stackoverflow.com/questions/10871574/how-does-geocoordinatewatcher-positionchaged-event-work-inside-a-periodic-task) – Rowland Shaw Nov 13 '15 at 13:17

1 Answers1

0

I think situation you've mentioned is the less important thing you should be worried about.

GeoCoordinateWatcher has much more serious limitations for Background Agent usage.

Unsupported APIs for background agents for Windows Phone

GeoCoordinateWatcher

This API, used for obtaining the geographic coordinates of the device, is supported for use in background agents, but it uses a cached location value instead of real-time data. The cached location value is updated by the device every 15 minutes.

In Windows Phone 8 you're able to run location-tracking app in background to bypass that limitation: Running location-tracking apps in the background for Windows Phone 8, however, it's not available for Windows Phone 7.5.

MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
  • It doesn't matter, that it uses cached location. Now I can't re-make my App for WP8. – Pupino Apr 07 '13 at 13:32
  • It does matter, because you'll get the same location for 15 minutes, no matter how much will it really change. – MarcinJuraszek Apr 07 '13 at 13:32
  • No it doesn't. You imagine: object A is on position XX.XXX/YY.YYY, it moves 1km, after 15min new location is cached with new coordinates. If I will stay 1hour on same place I get the same coordinates. I've tested it. When I was moving I got always other position. – Pupino Apr 07 '13 at 14:06