Google Play Fused Location and GPS - android

I need clarification on Google Play Fused Location.
I ask a high priority (LocationRequest.PRIORITY_HIGH_ACCURACY) but on my Android (4.4.4) I set the localization mode to Saving Battery: in this case Google Play don't use anyway the GPS, it's correct?
It think this because I try t use Google Play Fused Location, but if the GPS is off he use only the other methods for retrieve coords, and the obtained position is inaccurate (and I can't see the GPS icon on the status bar).
So, where is the advantage to use Fused Location? To retrieve an High accuracy position I need to set on the GPS anyway?
I really don't understand, thanks.

The advantage of the Fused Location API is that it combines and manages all the different types of location providers into one easy to use api where as if you wanted to use the built in LocationManager you have to manage them all yourself

Related

GPS & Google Location Services API vs Framework Location API (android.location)

I am working on an app that needs to access GPS status, and obtain data about visible satellites like Constellation type, is it used in position fix, Elevation egress etc. I've been using Android Framework Location API that has classes in android.location package for that, especially GnssStauts. Now, I see that Google recommends switching to using Location Services API from Google Play services because it does a lot of things instead of us (Geofencing, Activity Recognition...), and is more energy efficient and I understand that, I have started using it for getting user location. But, I cannot find out how to use it for more complex needs, like getting GPS satellites data, like I described in the beginning. Am I missing something very obvious here, or Google still didn't cover that type of use cases with new Location Services API (but forgot to mention that anywhere in documentation), so for that cases we should still stick to good old android.location framework?
THe Location Services API are an attempt to not use GPS, but try to calculate from additional sources like wifi, cellular signals, etc to save from having to power on the GPS chip. Generally its more accurate than network but less than GPS. (Technically I believe it can be forced to use just GPS, but it isn't the normal way of using it). If you need actual GPS data about satellites, it isn't going to help you. If you need to run on non-Google approved devices, it isn't going to help you (unless they pirate Google Play Services). For your usecase, I would skip it and just use the built in location code.

how to determine if latitude and longitude is accurate

I am currently using the Network(wifi, data plans) to get latitude and longitude for Android (and iOS) phone. The documentation states that the coordinates may not be accurate(GPS is more accurate). Therefore, how can I determine if the Lat/Long coordinates given to me are accurate? Or, if they are not, how can I determine how much off they are?
added note: not sure if that answers my question. HOw can i use these coordinates to see if it is accurate. Im not concerned with how to program it.
Check this blog post Android: Location Updates with the FusedLocationApi
He uses fused location API to parse location data and keep track if coordinates are accurate. Hope that helps.
You can set your request to high accuracy such as the following command:
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
And you can get the accuracy value from your location object such as:
myLocation.getAccuracy();
The best practice for the location to use the Fused Location API,

What is the difference to getting the location by using Location Manager and Fused Location Provider Api?

I need the real time difference to getting location using by Location Manager and Fused Api. I have checked with both, in Fused api(GPS) I am getting 7 digit after decimal point, but using by Location Manager(GPS) I will get nearly 15 digits after decimal point.
Which one is better to get accurate user current location?
What is the difference between Location Manager and Fused Api?
Why we need to migrate from Location Manager to Fused Api?
I used LocationRequest.PRIORITY_HIGH_ACCURACY, suppose I am in indoor, network is not available, how it returns the location?
Is it return the lastknown location, even I didn't write the code in onConnected()?
Related
Have found a previous answer for you, looks like FusedLocationProvider is going to be better
I think that the difference between them is that one use the physical sensor directly (Location Manager), where as other take assistance from the network/internet .
To me the more accurate is Location Manager but it takes some time and location detection speed depends on some factors such as you are on open place or not , weather etc..
I think the difference is:
Location Manager: you can choose specific resource provider such as
LocationManager.GPS_PROVIDER or LocationManager.NETWORK_PROVIDER
FusedLocation supplies a fast way to detect your location using combine of these provider above.

Are there any advantages of using FusedLocationProviderApi over LocationManager?

Earlier to get user current location I have used LocationManager:
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
It is easy to read and very straightforward code.
But I have noticed that Google recently released New Client API Model in Google Play Services and suggests to use FusedLocationProviderApi which looks like much more complicated, it is async, it requires to handle callbacks etc.
Are there any advantages of using FusedLocationProviderApi over LocationManager?
FusedLocationProvider uses a mix of hardware to determine location based on the context of the request, meaning it's optimized transparently to you. It will also cache captured locations between applications to avoid unnecessary work to determine location info. So if a user has a variety of location-aware apps, they potentially avoid taxing the device (and waiting) for a location capture as one may have already been cached.
While the ol' LocationManager will suffice in small, one-off situations, you should definitely consider the newer alternative as the benefits may be great, and the work to implement, easy.
You may as well use it as Google Play Services is regularly updated across devices, and continuously includes improvements to location-based features (and more).
A link to an explanation of the FusedLocationProvider at launch: https://www.youtube.com/watch?v=Bte_GHuxUGc
In some situations FusedLocationProvider performs horribly. If you want to track your path on a map for example, it may decide to switch between GPS data and Wifi data. To calculate an accurate distance travelled, it is much better to force GPS readings with LocationManager, especially if you also want to track altitude, which wifi doesn't provide.
Just keep in mind that FusedLocationProvider uses LocationManager under the covers to at least get GPS points. It may be performing Wifi scans and doing a look up on the results to determine location as well, instead of using the Network provider, but there isn't any documentation about this that I am aware of.
Unless you cannot or do not want to use FusedLocationProvider, I would recommend using it.

Receiving current location on Android

I've been working on an app that needs to be location-aware, and I've noticed that there are two (or more) methods of receiving location: with Google Play services (as seen here developer.android.com/training/location/retrieve-current.html#GetLocation) and with Location Manager, Providers etc. (as seen here http://www.vogella.com/tutorials/AndroidLocationAPI/article.html#locationapi_criteria).
What is the difference between these methods (if there is any)? Which one is more accurate?
edit: ok, I see that I sent the wrong link on the first thing. Won't this code (http://developer.android.com/training/location/receive-location-updates.html) give me location updates? Generally, what's the most accurate way to get my location?
The one with the GPS is accurate and that which is based on Network is not. Google Play Service use FUSE api to get the GPS location first, if the location is found (that's great), otherwise it will try to get location fix from Network Tower. In Short the one with GPS is accurate
The first method provides the details of LastKnownLocation. ie. the last location received from GPS or network provider when you or other apps accessed the location services. After that there are chances you moved a lot and it need not be your current location. So if You are planning to create an application that requires accurate location tracing, You should fetch the location as in the "Vogella" method. If the current location is unavailable, you can try using the last known location (As a plan B :-)).

Categories

Resources