Search code examples
androidgpslocationgoogle-api-client

How to find location accuracy?


How do I find the location accuracy of an android device running android 8 and below.

GoogleApiClient googleApiClient = new GoogleApiClient.Builder(context)
                .addApi(LocationServices.API).build();
        googleApiClient.connect();

        LocationRequest locationRequest = LocationRequest.create();
        locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
        locationRequest.setInterval(10000);
        locationRequest.setFastestInterval(10000 / 2);

I know there's a locationRequest.getPriority() method, but don't know how to use it. I need to find if the location is on device only mode at first before executing the above snippet. can you please demonstrate a way to find the location accuracy?

I want to know if the location is on High Accuracy or on Battery saver or on Device only mode


Solution

  • If you are using locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); and if the appropriate permissions are set on the AndroidManifest and if the user has chosen to provide the app with those permissions and if the device has GPS and Network connection, then by god's grace, you have the best location accuracy. About how much accurate your location data is, you can refer to the table below.

    Android Location Sensors

    Further Reading: HERE