We are currently working on an App that does a lot with users' locations. Therefore we are evaluating FusedLocationProviderClient and the "old" LocationManager to access the user's location over a long period of time.
The accuracy of the location is extremely important and we want to get the maximum out of the device. Initial testing showed great results with the "new" fused location provider. However, on some devices, this client is not available and in very rare cases the locations get really inaccurate after some time (<10min).
For some devices/cases we are thinking of using the "old" LocationManager, but my question is if this LocationManager will stick around in the future. I did some research but I wasn't able to find a lot of details. Google just "highly recommends switching to FusedLocationProviderClient", but it's missing some features of the LocationManager such as providing GNSS information.
Is it a good idea to use LocationManager and all the information that it provides such as GNSS Info?
Maybe some of you also did some research on this topic and can share the results.
How does the fusedLocationProviderClient work in fine/coarse permission modes ?
-
What is the minimum least required network to fetch coarse data ?
-
Is it possible with only Wifi ? (For a device with No SIM cards/eSiM)
-
Or a SIM card is a must to get the coarse mode to fetch approx. location ?
In all of the above cases, the location is turned on, I think its the permission that determines whether to use the GPS or not. So with only coarse persimmon given, what are the min requirements ?
Edit 1: I have tried with WiFi On/Off, location accuracy on/off, wifi scanning on/off, bluetooth scanning on/off, with/without connected to wifi. None of these are able to give me an approximate/Coarse location (returns null).
Edit 2: I don't want to get the FINE/Precise location. And yes, this mode works.
Weird!!! Fused location should be faster and should provide more accurate location.
Make sure you are requesting location updates
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this
);
instead of getting last known location
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient
);
and you're using LocationRequest.PRIORITY_HIGH_ACCURACY(GPS).
Main difference between Fused Location and Location Manager is the latter does not depend on Google Play Services.
Fused location doesn't work on a new handset or if a person has never used google.maps to get directions.
To get fused loction work you must ask the user to open once Google maps and get my location..but once that is done then fused location is best.
But for location finder in any app we can use mylocation layer and that gives accurate results even if the handset or user has never been exposed to maps..
I'm developing an Android app which performs certain actions based on user location. As of yet, I've made it work by using LocationListener and it is working fine.
But, I believe Google's put location API under Google Play services and released a newer API by the name of Fused Location, right? So my question is, what's the difference between these two approaches? I know the obvious one would be depending on Google Play services to fetch location in the case of Fused Location API. But other than that, which one is the better one to be used in a typical app that fetches user location at a specified interval and shows places of interests on the basis of that location?
Use the Fused Location API.
As the name suggests it's a 'fused' location provider, so it uses a mixture of GPS and network provided location to give you a trade-off between accuracy and battery consumption. It can also be updated independently of the OS, so it has a shorter release cycle for updates.
If you plan to release it on Amazon, F-Droid or anything other then the Play Store, stick with the LocationListener or implement both. There are quite a few people who don't have any Google stuff on their Android device, either because it's a cheap china phone or because they don't want El Goog to track their every move
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.
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..