Fused Location Provider in Android

15,037

Solution 1

Fused API provides 3 location providers.

  1. HIGH_ACCURACY
  2. BALANCED_POWER
  3. NO_POWER

The HIGH_ACCURACY mode use all location providers, However, it prioritize the location providers and include GPS along with location providers. The location accuracy is approximately within 10 meters of range.

The BALANCED_POWER mode exclude GPS for its list of location providers, and use the other providers based including cell towers, wifi etc. In this case, the location accuracy is approximately 40 meters.

The NO_POWER do not use any location provider, instead it is a passive mode of getting location from other apps. The accuracy could be a mile or more. It is solely based on the locations that are fetch by other applications recently.

Solution 2

If you are in-doors, GPS will probably not work. So it will fall back to wifi / triangulation.

Solution 3

If you use PRIORITY_HIGH_ACCURACY as in your example, it will use all available sources (wifi, cell, gps, and internal sensors). If you turn off wifi and are indoors, you probably can't get a gps lock (generally gps doesn't work indoors except in some areas when you're close to a window). If wifi, cell, and gps aren't available (either because they're turned off in settings or they're not available in your particular position), it won't return a location (internal sensors alone aren't enough to create a location from scratch).

Share:
15,037
Raja45
Author by

Raja45

Android Developer.

Updated on July 25, 2022

Comments

  • Raja45
    Raja45 almost 2 years

    I am developing an app using Fused Location Provider. I have a doubt. For getting location in regular intervals it uses requestLocationUpdates(). But from which source is it get the location either from WIFI or GPS or Network. In my app, it gets location in regular intervals only when WiFi is ON. When WiFi is in OFF state, then it can't get the location(it supposed to get location from some other source either form GPS or Network. But it never get location. Or i have to write listeners for GPS and Network). I don't know what is the problem. Can anyone help me.

    And, whether it works only when all the providers(Wifi,GPS,Network) available or else.

    public void checkPlay(){
    
      int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if (resp == ConnectionResult.SUCCESS) {
            locationClient = new LocationClient(this, this, this);
            locationClient.connect();
        } else {
            Toast.makeText(this, "Google Play Service Error " + resp,
                    Toast.LENGTH_LONG).show();
    
        }
     }
    
    
    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub
    
    
        if (locationClient != null && locationClient.isConnected()) {
    
            locationRequest = LocationRequest.create();
            locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
            locationRequest.setInterval(100);
            locationClient.requestLocationUpdates(locationRequest, this);
    
        }
    }
    
            public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub
        try {
            if (location != null) {
                lat = location.getLatitude();
                                long = location.getLongitude();
            }
        } catch (Exception e) {
            Log.d(Fots.TAG,
                    "GpsTrackService.mGpsLocationListener.onLocationChanged", e);
    
        }       
    }