Skip to content

Most visited

Recently visited

navigation
Added in API level 1

LocationListener

public interface LocationListener

android.location.LocationListener


Used for receiving notifications from the LocationManager when the location has changed. These methods are called if the LocationListener has been registered with the location manager service using the requestLocationUpdates(String, long, float, LocationListener) method.

Developer Guides

For more information about identifying user location, read the Obtaining User Location developer guide.

Summary

Public methods

abstract void onLocationChanged(Location location)

Called when the location has changed.

abstract void onProviderDisabled(String provider)

Called when the provider is disabled by the user.

abstract void onProviderEnabled(String provider)

Called when the provider is enabled by the user.

abstract void onStatusChanged(String provider, int status, Bundle extras)

Called when the provider status changes.

Public methods

onLocationChanged

Added in API level 1
void onLocationChanged (Location location)

Called when the location has changed.

There are no restrictions on the use of the supplied Location object.

Parameters
location Location: The new location, as a Location object.

onProviderDisabled

Added in API level 1
void onProviderDisabled (String provider)

Called when the provider is disabled by the user. If requestLocationUpdates is called on an already disabled provider, this method is called immediately.

Parameters
provider String: the name of the location provider associated with this update.

onProviderEnabled

Added in API level 1
void onProviderEnabled (String provider)

Called when the provider is enabled by the user.

Parameters
provider String: the name of the location provider associated with this update.

onStatusChanged

Added in API level 1
void onStatusChanged (String provider, 
                int status, 
                Bundle extras)

Called when the provider status changes. This method is called when a provider is unable to fetch a location or if the provider has recently become available after a period of unavailability.

Parameters
provider String: the name of the location provider associated with this update.
status int: OUT_OF_SERVICE if the provider is out of service, and this is not expected to change in the near future; TEMPORARILY_UNAVAILABLE if the provider is temporarily unavailable but is expected to be available shortly; and AVAILABLE if the provider is currently available.
extras Bundle: an optional Bundle which will contain provider specific status variables.

A number of common key/value pairs for the extras Bundle are listed below. Providers that use any of the keys on this list must provide the corresponding value as described below.

  • satellites - the number of satellites used to derive the fix
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.