Android Location Strategy - android

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

Related

current location on google maps without turning GPS on (android device)?

Is it possible for google maps to show my approximate location on maps without turning GPS on on my device? I understand it can not be very accurate but I am fine with that (even if shows location within a radios of 2km). I am having version 9.72.2 of google maps on my android device.
Thanks
Yes, if you have Internet access, it's possible via Google Maps Geolocation API and information about nearest mobile operator cell or/and wifi access points
You need send requests like:
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY
with information about target Cell Tower (how to get LAC and CID you can find here) or WiFi access point in request, and if target WiFi access point is in Google database your got response JSON with Lat/Lon and accuracy.
NB! But sometimes it returns completely wrong results.
For show current position you need to disable "standard" MyLocation tool
googleMap.setMyLocationEnabled(false);
and use custom, like described here.

Using Google play service can i get latest location in offline mode ( FusedLocationProviderApi)

using google play service we can get getLastLocation() which are using fused location provider to retrieve the device's last known location.
using change location i can set setPriority()
know to get current location form google doc
Once you have connected to Google Play services and the location services API, you can get the current location settings of a user's device
so my question is if i am not connected to network (internet connection) can i use the latest location of user not the last location the current location
yes sure you can get latest update location using GoogleApiClient. check this.
It has worked for me.Thank you.

Android's most accurate Location API

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.

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.

Get status of location providers with Google Play Services

I'm using the Google Play Services to get user's location and I can't find a way to get the status of the different location providers (network, gps).
I was looking for some equivalent of android.location.LocationListener's methods.
The point is, I have an activity with a map, it's supposed to display user's location, and if it's not available (because he didn't turn on his gps or whatever), the app prompts a Dialog to ask him to turn on.
Any idea ? :)

Categories

Resources