正在做关于GPS定位问题,现在发现从一个盲点到非盲点GPS定位正常,但是从非盲点到盲点的时候仍然获取到最后一个非盲点的经纬度,例如最后一个非盲点的坐标为a,b我到盲点之后获取的坐标一直保持为a,b,请给位大神帮主一下,这个是为什么,怎么解决啊

解决方案 »

  1.   

    查看location对象的时间信息Location.getTime()
    超过一定时间(与当前时间进行比较),你就将其判定为过期(已进入盲点)
    不过,这样可能会遇到一个问题(可能,我也不清楚),需要你注意一下
    如果你在一个非盲点,一直不动,
    不知道会不会获取新的location信息
      

  2.   

    当前时间是指的手机的时间吗,但是手机时间可能不准啊,那个Location.getTime获取的时间应该不是手机的时间吧
      

  3.   

    你即使在非盲点也是会获取新的location信息,但是问题是从非盲点进入盲点的时候那个location信息也是新的,那个时间不能用来判断
      

  4.   

    是啊,把两个点手机时间差和你设置的gps刷新时间相比较。如果手机时间差超过了刷新时间差,则证明进入了盲点了。
      

  5.   


    private static final int TWO_MINUTES = 1000 * 60 * 2;/** Determines whether one Location reading is better than the current Location fix
      * @param location  The new Location that you want to evaluate
      * @param currentBestLocation  The current Location fix, to which you want to compare the new one
      */
    protected boolean isBetterLocation(Location location, Location currentBestLocation) {
        if (currentBestLocation == null) {
            // A new location is always better than no location
            return true;
        }    // Check whether the new location fix is newer or older
        long timeDelta = location.getTime() - currentBestLocation.getTime();
        boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
        boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
        boolean isNewer = timeDelta > 0;    // If it's been more than two minutes since the current location, use the new location
        // because the user has likely moved
        if (isSignificantlyNewer) {
            return true;
        // If the new location is more than two minutes older, it must be worse
        } else if (isSignificantlyOlder) {
            return false;
        }    // Check whether the new location fix is more or less accurate
        int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
        boolean isLessAccurate = accuracyDelta > 0;
        boolean isMoreAccurate = accuracyDelta < 0;
        boolean isSignificantlyLessAccurate = accuracyDelta > 200;    // Check if the old and new location are from the same provider
        boolean isFromSameProvider = isSameProvider(location.getProvider(),
                currentBestLocation.getProvider());    // Determine location quality using a combination of timeliness and accuracy
        if (isMoreAccurate) {
            return true;
        } else if (isNewer && !isLessAccurate) {
            return true;
        } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
            return true;
        }
        return false;
    }/** Checks whether two providers are the same */
    private boolean isSameProvider(String provider1, String provider2) {
        if (provider1 == null) {
          return provider2 == null;
        }
        return provider1.equals(provider2);
    }