Question

background: I'm well versed in WPF/XAML, but new to Windows Phone 8.

Hopefully there is just something stupid that I'm missing...

I want DesiredAccuracy to be high, but I also want to hook into the PositionChanged event.

When the below code reaches _GeoLocator.DesiredAccuracy = PositionAccuracy.High; it throws an abort. If it off, everything works but I really want high accuracy.

It seems the two are mutually exclusive of one another.

Error message is: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)). I have Location capabilities enabled.

Example of offending code:

    public MainPage()
    {
        InitializeComponent();

        _GeoLocator.MovementThreshold = 1;

        _GeoLocator.PositionChanged += (Geolocator sender, PositionChangedEventArgs args) =>
        {
            //UpdateLocation(args);
            Console.WriteLine("Position Changed");
        };

        //THIS WILL THROW...WHY??   IF I COMMENT OFF POSITIONCHANGED ABOVE, IT WORKS FINE.
        _GeoLocator.DesiredAccuracy = PositionAccuracy.High;
    }
Was it helpful?

Solution

You have to set "DesiredAccuracy" before "PositionChanged" event handler (Similar question).

_GeoLocator.MovementThreshold = 1;
_GeoLocator.DesiredAccuracy = PositionAccuracy.High;
_GeoLocator.PositionChanged += (Geolocator sender, PositionChangedEventArgs args) =>
    {
        //UpdateLocation(args);
        Console.WriteLine("Position Changed");
    };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top