Is Fused Location Provider good choice?

23,016

Solution 1

When GPS is off and I set priority to HIGH, does that mean that GPS will be automatically turned on, or not?

No, it will not be turned on automatically. But if you use SettingsApi, will prompt a dialog to user and gives information that GPS is must be turned on. If user accepts it, the gps will be active automatically. Check the SettingsApi

How can I know what Fused provider is using (is it a GPS or a network provider)

If you use fused provider api with SettingsApi properly. It will make adequate the required settings for current location request.

Is Fused provider really the best choice for android location? Are there any negative points about it?

In my opinion, before fused provider you must deal with directly providers(Gps, network) But fused just asks you, "how accurate locations you wanna receive ?"

Solution 2

I made a testing application for Gps, Wifi and Fused Location Provider and testing it for 2 days. It's better because it uses both of them and most of the time it's the one most accurate. Also, Gps data is a very noisy data that causes jittering, to solve this low-pass filter or other filters are used. One of the most successful filter used to get most accurate results is Kalman Filter. FusedLocationProvider use this filter same as RotationVector which is a fused sensor combines hardware and software. RotationVector uses accelerometer, gyroscope(if available), and magnetic field sensor to get and filter positition and azimuth data.

Location.getProvider for Gps with LocationManager returns "gps", Wifi returns "network", and FusedLocationProvider returns "fused".

When GPS is off and I set priority to HIGH, does that mean that the GPS will be automatically turned on, or not

Anything other than "Battery Saving" turns Gps on if available. This settings available on my Android 7.1.1 phone. Setting for location was different on previous versions of Android on user's side. As a developer to enable using Gps you should set mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

PRIORITY_HIGH_ACCURACY - Use this setting to request the most precise location possible. With this setting, the location services are more likely to use GPS to determine the location.

Setting Priority also determines battery use level too.

Can I set UpdateLocation with Fused provider with HIGH priority on demand to save battery at least a little bit?

Yes, you can set interval of location request in addition to priority.

mLocationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
mLocationRequest.setFastestInterval(FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS);

How can I know what Fused provider is using (is it a GPS or a network provider)?

Location from Wifi never returns true for Location.hasSpeed() but Gps returns almost always true if you are outdoors. Also location.getExtras() have satellites tag which you can check for satellites which is only available for Gps. Speed may not be correct if you are walking or as far i've read so far, i haven't tried this on car, when speed it less than 5km/h it's not very accurate. I mean if you are using FLP and last location data contains speed info it's definitely from Gps.

Are there any negative points about it?

As of Android 8.0 and above there is location retrieving limit if you do not use a Foreground Service or get location on foreground while app is not paused for both FLP and LocationManager.

Also FLP requires GooglePlayService to be available on user's device and it should be above a particular version. 10 or 11 depending on which one you use. This can be trouble if you wish to publish your apps on a country, for example China, that bans Google Play Services.

Solution 3

As in here https://developer.android.com/training/location/index.html stated very clearly that, the Google Play services location APIs are preferred over the Android framework location APIs (android.location) as a way of adding location awareness to your app. If you are currently using the Android framework location APIs, you are strongly encouraged to switch to the Google Play services location APIs as soon as possible. So I hope you got your answer.

Solution 4

The existing answers don't say why the FusedLocationProvider is better.

It is better because the API fuses from more data sources (sensors, wifi, context, history) in an intelligent and battery-saving way. Also, Google is always improving it by adding more data sources. If your app uses it, you get those improvements for free.

Share:
23,016
Atenica
Author by

Atenica

Updated on July 26, 2022

Comments

  • Atenica
    Atenica almost 2 years

    I am developing an application where I want to use Fused Location Provider. But I have some doubts, and couple of questions.

    1. When GPS is off and I set priority to HIGH, does that mean that the GPS will be automatically turned on, or not?
    2. Can I set UpdateLocation with Fused provider with HIGH priority on demand to save battery at least a little bit?
    3. How can I know what Fused provider is using (is it a GPS or a network provider)? And finally
    4. Is Fused provider really the best choice for android location? Are there any negative points about it?

    What is your opinion? Thanks in advance.

  • Atenica
    Atenica almost 8 years
    So, that means that Fused provider is really the best? :)
  • Mahendra Chhimwal
    Mahendra Chhimwal almost 8 years
    Yes. At least that is what Android official DOCs says. And I see no reasons to not use Fused APIs.
  • Atenica
    Atenica almost 8 years
    Just one more question...whe I use HIGH priority and in docs writes that interval is about 5 seconds..is that mean that on every 5 seconds location is updating or that means that we must wait for 5 seconds to get our location?
  • Mahendra Chhimwal
    Mahendra Chhimwal almost 8 years
    When we set interval to location Request object, it means every 5 sec we will get update of new location. If FusedApi have location updates for other apps, it can provide you an update even before interval. For minimizing that there is API setFasInetrval(long miliseconds).
  • Atenica
    Atenica almost 8 years
    Just 2 more questions I have and then I will stop bodering you..:) Is this Fused provider works when app is in backgroun ro is killed and another question is, when we look to longitude and latitude we can see part where writes "accuracy"..what that means? Accurate from where?
  • The incredible Jan
    The incredible Jan over 6 years
    "If you use fused provider api with SettingsApi properly. It will make adequate the required settings for current location request." is no answer to the question. I really hate it not to know where fused provider got it's location from. I learned the hard way that you can't trust the accuracy value. Accuracy is completely pointless if location is not from GPS or GSM.
  • The incredible Jan
    The incredible Jan over 6 years
    @Mahendra Chhimwal No reasons against Fused API? Only if you don't care about completely wrong coordinates from WLAN which are declared as accurate by Google...
  • The incredible Jan
    The incredible Jan over 6 years
    It is not better because many of the location providers are not reliable and Google still claims their locations as very accurate. Wifi locations sometimes REALLY suck and you can't sort them out.
  • blackkara
    blackkara over 6 years
    Yes, i know, suggesting to use 'Settings Api' is not answer. But, we should be interesting with how accurate location is, instead of which of them(GPS, NETWORK) is/are used when using fused location provider. So the Settings Api will make guaranteed your location request's priority. Btw, up to now i received high accurate locations from fused provider via PRIORITY_HIGH_ACCURACY and proper settings.
  • Saitama
    Saitama over 6 years
    what if the user is in China and has no google play service installed on his phone, then fusedLocation won't work AT ALL, right?
  • ZephDavies
    ZephDavies over 5 years
    "Location from Wifi never returns true for Location.hasSpeed() but Gps returns almost always true if you are outdoors. Also location.getExtras() have satellites tag which you can check for satellites which is only available for Gps. " Thank you for this. Very helpful. In terms of which is "better", depends on your need case. If you ONLY want GPS results, perhaps FLP is not the best?