Monday, February 4, 2013

Android Location Providers – gps, network, passive

There are 3 location providers in Android.


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.

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,time,distance,listener);

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.

locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,time,distance,listener);

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

<receiver android:name=".PassiveLocationChangedReceiver" android:enabled="true"/>

Alsoyou can Get Location using Following:

Cached GPS: Most Androids have the ability to store the last know GPS location. This is typically used when an application first starts up, and you can retrieve the timestamp, latitude, longitude and accuracy.

locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);


Cached Network: Android devices can also store the last known location as determined by the cellular carrier’s network location provider. The provider gathers information from the cell network and WiFi, if it’s turned on, then sends that off to a remote server-side process that crunches the information and sends back an approximate location. This is not available in all countries.  Just like the GPS, you’ll typically retrieve the timestamp, latitude, longitude and accuracy.

locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

NMEA: Although it’s not human readable, you can get access to the raw NMEA strings. Typically these strings are used for programmatic access and would only make sense to a developer or engineer. This data is often used in maritime apps. The data is only available once the GPS has warmed up, which is a concept discussed in more detail below.

addNmeaListener(GpsStatus.NmeaListener);


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


  • Fine-grained location provider like the GPS provider with an accuracy of less than 100 m.
  • Coarse-grained location provider like the network location provider with an accuracy of 100 – 500 m

No comments:

Post a Comment