Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Fused Location Provider good choice?

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.

like image 671
Atenica Avatar asked Jun 28 '16 09:06

Atenica


4 Answers

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 ?"

like image 197
blackkara Avatar answered Oct 17 '22 08:10

blackkara


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.

like image 33
Mahendra Chhimwal Avatar answered Oct 17 '22 06:10

Mahendra Chhimwal


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.

like image 28
Thracian Avatar answered Oct 17 '22 07:10

Thracian


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.

like image 4
Mark Lu Avatar answered Oct 17 '22 08:10

Mark Lu