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 LocationManager#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.

default void onProviderDisabled(String provider)

Called when the provider is disabled by the user.

default void onProviderEnabled(String provider)

Called when the provider is enabled by the user.

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

This method was deprecated in API level 29. This callback will never be invoked on Android Q and above.

Public methods

onLocationChanged

Added in API level 1
public abstract void onLocationChanged (Location location)

Called when the location has changed.

Parameters
location Location: the updated location This value cannot be null.

onProviderDisabled

Added in API level 1
public 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 that has become disabled This value cannot be null.

onProviderEnabled

Added in API level 1
public void onProviderEnabled (String provider)

Called when the provider is enabled by the user.

Parameters
provider String: the name of the location provider that has become enabled This value cannot be null.

onStatusChanged

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

This method was deprecated in API level 29.
This callback will never be invoked on Android Q and above.

This callback will never be invoked on Android Q and above, and providers can be considered as always in the LocationProvider#AVAILABLE state.

Parameters
provider String

status int

extras Bundle