0

I´m having a problem using the plugin "Xam.Plugin.Geolocator 4.5.0.6" i get all the info that i want but the time stamp that it prints is like 6 days ago and i really don´t now why. See down here:

This is the code for output:

private async void PositionChanged(object sender, PositionEventArgs e)
{
    (here i got other stuff but not related to this just some json that i will use later)

        // output de teste------------------------
        var positions = e.Position;
        var output = "Full: Lat: " + positions.Latitude.ToString() + " Long: " + positions.Longitude.ToString();
        output += "\n" + $"Time: {positions.Timestamp.ToUnixTimeMilliseconds().ToString()}";//atenção este add hora foi para retornar a hora de Portugal UTC +01:00
        output += "\n" + $"Heading: {positions.Heading}";
        output += "\n" + $"Speed: {positions.Speed}";
        output += "\n" + $"Accuracy: {positions.Accuracy}";
        output += "\n" + $"Altitude: {positions.Altitude}";
        output += "\n" + $"Altitude Accuracy: {positions.AltitudeAccuracy}";
        Debug.WriteLine(output);
    }
}

And this is the one that start the event above showed:

public async Task StartLocAsync()
{

    if (CrossGeolocator.Current.IsListening)
        return;

    await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(5), 10, true);

    CrossGeolocator.Current.PositionChanged += PositionChanged;
    CrossGeolocator.Current.PositionError += PositionError;
}

And this is the output:

09-18 13:15:42.052 D/Mono (32302): Found as 'java_interop_jnienv_is_assignable_from'. 09-18 13:15:42.178 I/Choreographer(32302): Skipped 35 frames! The application may be doing too much work on its main thread. [0:] Full: Lat: 25.422 Long: -170.084 Time: 1536750935000 Heading: 0 Speed: 0 Accuracy: 20 Altitude: 0 Altitude Accuracy: 0 [0:] Full: Lat: 25.422 Long: -170.084 Time: 1536750935000 Heading: 0 Speed: 0 Accuracy: 20 Altitude: 0 Altitude Accuracy: 0 Thread finished: #5

The time in the output is in unix, but when convert to the normal format date it display the day 12 instead of the day 18 that is today.

Thanks any help.

Tiago dias
  • 133
  • 13
  • Is this on a simulator/emulator, or a real device? – Andrew Sep 18 '18 at 14:47
  • 1
    are you consistently getting the wrong timestamp if you listen for multiple updates, or is it only the first one that is incorrect? Have you verified the system date/time on the device? Have you tested with more than one device? – Jason Sep 18 '18 at 14:48
  • @Andrew I'm just tryng for now in the emulator (Android 6.0 API 23). – Tiago dias Sep 18 '18 at 14:54
  • @Jason I get this error everytime i test in the emulator, but the date and time on the android emulator is correct. When i covert from unix to real date the day is the only think that is not correct the rest is correct with the reality – Tiago dias Sep 18 '18 at 14:56
  • @Jason i see you got the solution for me in other question, thank you. – Tiago dias Sep 18 '18 at 14:58

0 Answers0