Search code examples
androidandroid-location

Location.getProvider always return "fused" not GPS or Network


I am using the fused location API:

        locationrequest = LocationRequest.create();
        locationrequest.setInterval(interval);
        locationrequest.setFastestInterval(interval);
        locationrequest.setSmallestDisplacement(0);

        locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

        LocationServices.FusedLocationApi.requestLocationUpdates(locationClient, locationrequest, this);

And whenever I get a location, I do loc.getProvider and I always get the string "Fused".

I was expecting Network vs GPS or some other indication.

Any ideas?


Solution

  • This is the expected behavior of the FusedLocationApi - it combines services in order to reduce power usage and for a variety of other reasons.

    If you need to use a specific provider, you'll want http://developer.android.com/reference/android/location/package-summary.html

    As that page says, this is not the recommended way to get location.

    If you're interested in handling the accuracy of returned locations, it's better to do this on an update by update basis - using Location.getAccuracy()