Android's most accurate Location API - android

In order to work, my app requires a location API.
I intend use the Mapbox platform to customize its design (since Google Maps
does not provide this level of customization, as far as I am concerned).
Documentation says that we should use Google Play API when building location
apps:
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.
My question is:
Is Google Play API the most efficient API when it comes to GPS accuracy?
Or should I use the LocationManager and LocationListener way of doing it?
I need accuracy. Which one should I use?
Thanks.

In android also there are three types of location :
GPS_PROVIDER
NETWORK_PROVIDER
PASSIVE_PROVIDER
So, as per my coding experience I came to know that if you use :
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, new MyLocationListener());
you will get precision upto 14+ decimal places.
But if you use fusion of them like this :
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, my_google_listener);
you will get precision upto 6 to 7 decimal places. try it !!! reference
But note few things here that, GPS Provider takes time to fetch location while Google Location is much faster as it gets data from API call to its google server database.
GPS works offline while google provider gets the location via mobile or wifi data.

Use FusedLocationProviderApi and set LocationRequest priority to PRIORITY_HIGH_ACCURACY
This is newest API for accurate location fetch and google suggest to use the same.
Check Accuracy details here.
Basically Google play services API has intelligence to get accurate location by fusing GPS+NetworkProvider+passive providers.

FusedLocationProviderApi is deprecated.You should use FusedLocationProviderClient and you should add ACCESS_FINE_LOCATION permission,not ACCESS_COARSE_LOCATION to get the most accurate location.
And read this article to understand why FusedLocationProviderClient is the best solution.

In my experience, the Google Services Location API are preferable to use in following aspects:
they deal with user settings, choosing the best available location provider. If you choose to work with LocationManager directly, your code will need to handle that.
you might expect to get a better location with less power usage, as Google regularly updates their algorithms for determining location using WiFi, cell towers, etc.
In my experience, using Google Services, location with accuracy sufficient for a mapping application (that is some tens meters) in many cases does not require GPS data. That might also be the case with FusedLocationProvider, though, maybe with an exception for the battery usage numbers.
To conclude, if you don't have arguments to NOT use Google Services (such as - you target a country where they are not available, or want to distribute via alternative markets) you should use their Location API.

Related

Using Google Play Services in Android ; is there a way to get the Location from only GPS?

Using Google Play Services 's Location Service , is there a way to specify that we get the Location only from GPS device on the android device?
This should be a handy guide in telling you how to request your location strictly from the GPS. Be sure to read carefully in the Requesting Location Updates section.
Granted, this is not using the Google Play Services Location Service, but I believe the difference between the two is that, by using Google Play, you can skip the step of calling both GPS_PROVIDER and NETWORK_PROVIDER. Additionally, Google Play Services Location Service stores the most recent Location in the GoogleApiClient so you're not completely out of luck when neither of the providers are working.
Edit
Short answer - No
Long answer:
According to Google's source code, they use the same functions I listed earlier. As far as higher accuracy is concerned, that is obtained through the combination of GPS_PROVIDER and NETWORK_PROVIDER data. A workaround could possibly be passing the FusedLocationProviderApi GPS-only locations through the setMockLocation method.

Android Location Strategy

In Android What are the location determination strategies for
Real-time GPS location determination (for user real-time user location tracking).
Periodic GPS location determination (for periodic user location determination).
For most accurate GPS location value.
I am trying to make mobile applications of type 1 and type 2. Please guide me regarding the same
You can use Google Play Services API which is friendly and simple to use or GPS location API directly. Google Play Services API can return current user location or you can even subscribe to location updates. Take look official documentation.
Also there is not only GPS, but also mobile Network and Wi-Fi based location built in in Android. You can use all of them simultaneously thru FusedLocation provider to determine user location.
Location APIs
Location Strategies

Using fused location provider via LocationManager

I'd like to use the fused location provider via the Android LocationManager API because:
I'd prefer not to make the app, Phonelocator, dependent on google play services
The existing implementation is already working and tested
It appears that the this is possible. Just pass the the string "fused" as a location provider on a phone with google play services installed.
I'd like the option to use the PRIORITY_HIGH_ACCURACY profile. I suspect that, by default, it's not being used.
Has anybody worked out how to do this?
You should check out the android-play-location samples, as they demonstrate how to use FusedLocationApi. Something like:
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

ways of getting my location on android

This may be a kinda odd question but I am new at Android development and I'm having trouble to learn how to retrieve the user's location to my application. I have looked for this topic but I just can't find a statisfying answer.
To get the user location I have found two ways:
http://developer.android.com/training/location/retrieve-current.html . This one is using what I think is the new Google Services release which uses a LocationClient to connect to Google Services and retrieve the location.
http://developer.android.com/guide/topics/location/strategies.html . The other one is using the android.location class and a LocationManager to retrieve the location.
The thing is that I don't get the difference between using one way or the other, which one is better??
And another question is that in the second way you can specify which location provider you want to use, if the GPS provider or the Network provider and in the first one you can't, but in the first paragraph it says that it uses the location sensors that are currently active for the device. Does this mean that I don't have to worry about choosing between both services??
I am using Android Studio and I have set up the new Google Services release, I just need to know the pros and cons between both ways to know which one to use and to begin learning.
Thanks!!
As stated in the second link:
The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy. It also handles location update scheduling based on power consumption parameters you provide. In most cases, you'll get better battery performance, as well as more appropriate accuracy, by using the Location Services API.
I would highly recommend you to watch the last I/O video to get a simple explanation from Reto Meier about the new Location Provider: http://youtu.be/GcNNx2zdXN4?t=14m29s (I suggest you to watch the entire clip btw, it's inspiring).

How does google maps get location on android device?

I am an android developer and have been using it for a while to develop context-aware apps. Location is one of the most important thing for context aware and accuracy of that location is very important.
I know how to get location from GPS using LocationManager... I know how to develop apps using Google maps on android... and also how to display user on the map.. etc. But my friends have found out that when they went to a foreign country for a conference, their location from LocationManager is very inaccurate compare to google maps.
They used my app (not released yet.. ) which I get my location from LocationManager and I registered for GPS and Network provider. If I plot the location that the phone gives me on a map... it's very inaccurate... some times it thinks the user is in Barcelona even though they are at a conference in USA.
Also since the conference was indoor, the GPS wouldn't have helped a lot because it would've had hard time finding a fix.
Does google maps on android get their location similar to how google tells the android developers to get the location... from LocationManager and register for onLocationChanged location listener? If it does... how come theirs is more accurate... how do they filter any outliers? or are they using any internal services to get even more accurate location which maybe google assume that if the developer get that accurate location they could misuse it?
Any ideas or comments??
This code is written by Reto Meier, Tech Lead for Android Developer Relations, who wrote the book on Android App development. Also, that was published in Google IO conference in 2011 as I remember. This is the closest to what is used in Google Places. And it works smart anyway ;)
https://code.google.com/p/android-protips-location/

Categories

Resources