Android GPS位置不准确

时间:2017-09-15 22:05:03

标签: android gps location android-gps

所以我有一个计时器,我每10秒运行一次,更新我的GPS位置并将其插入我的数据库。问题是位置永远不准确,我不是指米,我的意思是有时半英里到一英里。我在手机上尝试过多种设置,但没有一种能解决这个问题。我也在我的应用程序旁边使用了Stride GPS跟踪应用程序,并且Stride精确地确定了我的地方到处都是。有什么建议吗?

这是我的电话:

Location loc = GPS.sharedInstance(Dashboard.this).getLastKnownLocation();
                            double e_lat = GPS.sharedInstance(Dashboard.this).getLatitude();
                            double e_long = GPS.sharedInstance(Dashboard.this).getLongitude();
                            GPS.sharedInstance(Dashboard.this).updateLocation(e_lat, e_long);

GPS.java:

public Location getLastKnownLocation() {
    if (ActivityCompat.checkSelfPermission(_activity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        _isPermissionEnabled = false;
    } else {
        if (_canGetLocation) {
            if (_isNetworkEnabled)
            {
                _locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                if (_locationManager != null)
                {
                    _location = _locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);


                    if (_location != null)
                    {
                        _latitude = _location.getLatitude();
                        _longitude = _location.getLongitude();
                    }
                }
            }

            if (_isGPSEnabled)
            {


                if (_location == null)
                {

                    _locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                    if (_locationManager != null)
                    {
                        _location = _locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);


                        if (_location != null)
                        {
                            _latitude = _location.getLatitude();
                            _longitude = _location.getLongitude();
                        }
                    }
                }
            }
        }
    }

    return _location;
}

public double getLatitude() {
    if (_locationManager != null) {
        _latitude = _location.getLatitude();
    }

    return _latitude;
}

public double getLongitude() {
    if (_locationManager != null) {
        _longitude = _location.getLongitude();
    }

    return _longitude;
}

0 个答案:

没有答案
相关问题