为什么Geolocation收到错误的时间戳-Xamarin

时间:2018-09-18 14:40:32

标签: xamarin xamarin.forms xamarin.android

我在使用插件“ Xam.Plugin.Geolocator 4.5.0.6” 时遇到了问题,我得到了我想要的所有信息,但打印的时间戳大约是6天前,我现在真的不知道为什么。在这里查看:

这是输出代码:

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);
    }
}

这是开始上述事件的那一个:

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;
}

这是输出:

  

09-18 13:15:42.052 D / Mono(32302):找到为“ java_interop_jnienv_is_assignable_from”。 09-18 13:15:42.178 I / Choreographer(32302):跳过了35帧!该应用程序可能在其主线程上做太多工作。 [0:]完整:纬度:25.422长:-170.084时间:1536750935000航向:0速度:0精度:20海拔:0海拔精度:0 [0:]完整:纬度:25.422宽:-170.084时间:1536750935000航向: 0速度:0精度:20海拔:0海拔精度:0螺纹加工:#5

输出中的时间以Unix为单位,但是转换为正常格式的日期时,它将显示第12天而不是今天的第18天。

谢谢您。

0 个答案:

没有答案