Using fused location provider via LocationManager - android

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);

Related

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.

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

Google Play Services LocationClient returns null

I am new to android and I want to get the current location for which I am referring to the link http://developer.android.com/training/location/retrieve-current.html which shows the use of Google Play Services.
To start with I have downloaded the sample LocationUpdates from the above link and I am using an emulator(AVD with target Google API Inc,API Level 17,Platform 4.2.2).
I am trying to get the current Location and it returns null.It uses LocationCLient and makes a call mLocationClient.getLastLocation().
Check is made if Google Play Services are available by using GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); here it returns 0(success).
I have enabled the Location access in the emulator:Wifi and GPS Satellites.
Please help me to know what is mising so that I get the current location.
Thanks
Try opening Google Maps on the emulator once so that the Google Play Services can update, then enable "Access Location" from the Google Settings application under "Google Location".
After doing this I was able to manually push GPS-locations to the device using the emulator controls and accessing them from the LocationClient.
If both your WiFi and GPS services are enabled,is your device actually connected to WiFi too? If not, your WiFi service won't be working, and the location provider will fall back to GPS. GPS will not be quick enough to get your location which lead the value (getLastLocation()) to be null sometimes.

Categories

Resources