Android Location getTime() 添加 1 天错误

发布于 2024-12-27 07:25:56 字数 461 浏览 3 评论 0原文

我目前使用的是三星 Galaxy Tab P1000,但我遇到了一个问题,我不确定是否会在所有智能手机上发生。 同步GPS时,每次我获取location.getTime();它返回实际日期加上 1 天。我做错了什么还是这是一个错误?

代码如下:

@Override
    public void onLocationChanged(Location location) {
        setRealTime(location.getTime()); 
        ...
        data = new Date();
        data.setTime(getRealTime());
    }

然后例如,今天是 15:31 01/16 它显示 15:31 01/17

问题仅出现在 Samsung Galaxy Tab P1000 中......

有什么想法吗?

I'm currently using a Samsung Galaxy Tab P1000, and I'm stuck in a problem that I don't know for sure if happens in all smartphones.
When synchronizing the GPS, everytime I get the location.getTime(); it returns the actual date plus 1 day. Am I doing something wrong or is this a bug?

Here is the code:

@Override
    public void onLocationChanged(Location location) {
        setRealTime(location.getTime()); 
        ...
        data = new Date();
        data.setTime(getRealTime());
    }

And then for example, it today is 15:31 01/16 it shows 15:31 01/17

The Problem is exclusively in the Samsung Galaxy Tab P1000...

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北座城市 2025-01-03 07:25:56

这是三星固件中的闰年错误,已得到三星证实。请参阅 Android :Samsung Galaxy Tabs 和 Android 2.2 Devices Showing GPS date 1 Day Advance from 1st jan 2012

该答案显示了一些可以解决该问题的代码;简短版本是使用 NmeaListener 而不是 LocationListener。它可能会在 2 月 29 日自行修复......

This is a leap year bug in Samsung firmware, confirmed by Samsung. See Android : Samsung Galaxy Tabs and Android 2.2 Devices Showing GPS date 1 Day Advance from 1st jan 2012

That answer shows some code which works around it; short version is to use an NmeaListener instead of a LocationListener. And it may fix itself on Feb 29th...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文