Samsung Tab GPS精度水平始终超过10m吗?

时间:2018-07-30 06:11:53

标签: java android gps

我使用android SDK开发了一个土地面积计算应用程序。在过去的四年中,它的表现非常出色。 GPS精度等级低于10m。但是今年(2018年1月或2月)该应用程序不再运行良好,GPS精度级别为10m或更高。我使用Samsung Tab。有什么问题吗?

这是点捕获代码:

private void setPoints() {


 try {

        if (isGPSEnabled() && isNetworkEnabled()) {

            AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);

            locationManager = (LocationManager) context
                    .getSystemService(LOCATION_SERVICE);

            if (ActivityCompat.checkSelfPermission(this, ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    ActivityCompat#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for ActivityCompat#requestPermissions for more details.
                return;
            }
            currentLocation = locationManager
                    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
            /*currentLocation = LocationServices.FusedLocationApi
                    .getLastLocation(locationClient);*/


            double longitude = currentLocation.getLongitude();
            double lattitude = currentLocation.getLatitude();
            double altitude = currentLocation.getLongitude();
            double accuracy = currentLocation.getAccuracy();

            Log.d("Accuracy", "Accuracy " + accuracy + "longitude: " + longitude + "lattitude: " + lattitude);

            alertDialog.setMessage(String.valueOf(longitude) + "..." + String.valueOf(lattitude));

            if (longitude > 0 && lattitude > 0) {

                if (accuracy <= KmlHome.ACCURACY_LEVEL) {
                    capturePointAlert(longitude, lattitude, altitude,
                            accuracy,
                            ElandConstant.ADD_POINT_SUCCESS_ASK_STR,
                            "Capture Point", "YES", R.drawable.ok);
                } else {
                    displayAlert(ElandConstant.ACCURACY_LEVEL_STR + " ( "
                                    + accuracy + " m ) \n Try again.",
                            ElandConstant.ACCURACY_LEVEL_TITLE_STR, "OK",
                            R.drawable.warning);
                }
            } else {
                displayAlert(ElandConstant.NO_GPS_SIGNAL_STR,
                        ElandConstant.GPS_TITLE_STR, "OK", R.drawable.wrong);
            }
        } else {
            displayAlert(ElandConstant.NO_GPS_SIGNAL_STR,
                    ElandConstant.GPS_TITLE_STR, "OK", R.drawable.wrong);
        }

    } catch (Exception e) {
        e.printStackTrace();
        AlertDialog alertDialog = new AlertDialog.Builder(LocationMapper.this).create();
        alertDialog.setTitle("Alert");
        alertDialog.setMessage((CharSequence) e);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }

}

0 个答案:

没有答案