Android Location Providers - GPS or Network Provider?

AndroidLocationLocation Provider

Android Problem Overview


In my application I would like to determine the user's current location. I do however have a couple of questions in this regard:

  1. There are different Location Providers, which one is the most accurate? The GPS Provider or the Network Provider?

  2. In how far do those available provider differ? How do they function?

  3. Could you please provide me with some code-snippets or tutorials on how to get started with implementing GPS functionality in my application?

Android Solutions


Solution 1 - Android

> There are 3 location providers in Android. > > They are: > > gps –> (GPS, AGPS): Name of the GPS location provider. This > provider determines location using satellites. Depending on > conditions, this provider may take a while to return a location fix. > Requires the permission android.permission.ACCESS_FINE_LOCATION. > > network –> (AGPS, CellID, WiFi MACID): Name of the network > location provider. This provider determines location based on > availability of cell tower and WiFi access points. Results are > retrieved by means of a network lookup. Requires either of the > permissions android.permission.ACCESS_COARSE_LOCATION or > android.permission.ACCESS_FINE_LOCATION. > > passive –> (CellID, WiFi MACID): A special location provider for > receiving locations without actually initiating a location fix. This > provider can be used to passively receive location updates when other > applications or services request them without actually requesting the > locations yourself. This provider will return locations generated by > other providers. Requires the permission > android.permission.ACCESS_FINE_LOCATION, although if the GPS is not > enabled this provider might only return coarse fixes. This is what > Android calls these location providers, however, the underlying > technologies to make this stuff work is mapped to the specific set of > hardware and telco provided capabilities (network service). > > The best way is to use the “network” or “passive” provider first, > and then fallback on “gps”, and depending on the task, switch between > providers. This covers all cases, and provides a lowest common > denominator service (in the worst case) and great service (in the best > case).

enter image description here

Article Reference : [Android Location Providers - gps, network, passive By Nazmul Idris] 2

Code Reference : https://stackoverflow.com/a/3145655/28557

-----------------------Update-----------------------

Now Android have Fused location provider

The Fused Location Provider intelligently manages the underlying location technology and gives you the best location according to your needs. It simplifies ways for apps to get the user’s current location with improved accuracy and lower power usage

Fused location provider provide three ways to fetch location

  1. Last Location: Use when you want to know current location once.
  2. Request Location using Listener: Use when application is on screen / frontend and require continues location.
  3. Request Location using Pending Intent: Use when application in background and require continues location.

References :

Official site : http://developer.android.com/google/play-services/location.html

Fused location provider example: GIT : https://github.com/kpbird/fused-location-provider-example

http://blog.lemberg.co.uk/fused-location-provider

--------------------------------------------------------

Solution 2 - Android

GPS is generally more accurate than network but sometimes GPS is not available, therefore you might need to switch between the two.

A good start might be to look at the android dev site. They had a section dedicated to determining user location and it has all the code samples you need.

http://developer.android.com/guide/topics/location/obtaining-user-location.html

Solution 3 - Android

There are some great answers mentioned here. Another approach you could take would be to use some free SDKs available online like Atooma, tranql and Neura, that can be integrated with your Android application (it takes less than 20 min to integrate). Along with giving you the accurate location of your user, it can also give you good insights about your user’s activities. Also, some of them consume less than 1% of your battery

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNomanView Question on Stackoverflow
Solution 1 - AndroidVinayak BevinakattiView Answer on Stackoverflow
Solution 2 - AndroidOtraView Answer on Stackoverflow
Solution 3 - AndroidjohndalyView Answer on Stackoverflow