Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# LocationListener

*** ** * ** ***

` public interface LocationListener `   
` `

|---|
| android.location.LocationListener |

<br />

*** ** * ** ***

Used for receiving notifications when the device location has changed. These methods are called when the listener has been registered with the LocationManager.

### Developer Guides

For more information about identifying user location, read the [Obtaining User Location](https://developer.android.com/guide/topics/location/obtaining-user-location) developer guide.

<br />

**See also:**

- `https://developer.android.com/reference/android/location/LocationManager#requestLocationUpdates(java.lang.String,%20android.location.LocationRequest,%20java.util.concurrent.Executor,%20android.location.LocationListener)`

## Summary

| ### Public methods ||
|---|---|
| ` default void` | ` https://developer.android.com/reference/android/location/LocationListener#onFlushComplete(int)(int requestCode) ` Invoked when a flush operation is complete and after flushed locations have been delivered. |
| ` default void` | ` https://developer.android.com/reference/android/location/LocationListener#onLocationChanged(java.util.List<android.location.Location>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/location/Location> locations) ` Called when the location has changed and locations are being delivered in batches. |
| ` abstract void` | ` https://developer.android.com/reference/android/location/LocationListener#onLocationChanged(android.location.Location)(https://developer.android.com/reference/android/location/Location location) ` Called when the location has changed. |
| ` default void` | ` https://developer.android.com/reference/android/location/LocationListener#onProviderDisabled(java.lang.String)(https://developer.android.com/reference/java/lang/String provider) ` Called when the provider this listener is registered with becomes disabled. |
| ` default void` | ` https://developer.android.com/reference/android/location/LocationListener#onProviderEnabled(java.lang.String)(https://developer.android.com/reference/java/lang/String provider) ` Called when a provider this listener is registered with becomes enabled. |
| ` default void` | ` https://developer.android.com/reference/android/location/LocationListener#onStatusChanged(java.lang.String,%20int,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String provider, int status, https://developer.android.com/reference/android/os/Bundle extras) ` *This method was deprecated in API level 29. This callback will never be invoked on Android Q and above.* |

## Public methods

### onFlushComplete

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onFlushComplete (int requestCode)
```

Invoked when a flush operation is complete and after flushed locations have been delivered.

<br />

| Parameters ||
|---|---|
| `requestCode` | `int`: the request code passed into `https://developer.android.com/reference/android/location/LocationManager#requestFlush(java.lang.String,%20android.location.LocationListener,%20int)` <br /> |

### onLocationChanged

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onLocationChanged (List<Location> locations)
```

Called when the location has changed and locations are being delivered in batches. The default implementation calls through to `https://developer.android.com/reference/android/location/LocationListener#onLocationChanged(android.location.Location)` with all locations in the batch. The list of locations is always guaranteed to be non-empty, and is always guaranteed to be ordered from earliest location to latest location (so that the earliest location in the batch is at index 0 in the list, and the latest location in the batch is at index size-1 in the list).

<br />

| Parameters ||
|---|---|
| `locations` | `List`: the location list. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/location/LocationRequest#getMaxUpdateDelayMillis()`

### onLocationChanged

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onLocationChanged (Location location)
```

Called when the location has changed. A wakelock may be held on behalf on the listener for some brief amount of time as this callback executes. If this callback performs long running operations, it is the client's responsibility to obtain their own wakelock if necessary.

<br />

| Parameters ||
|---|---|
| `location` | `Location`: the updated location. This value cannot be `null`. <br /> |

### onProviderDisabled

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onProviderDisabled (String provider)
```

Called when the provider this listener is registered with becomes disabled. If a provider is disabled when this listener is registered, this callback will be invoked immediately.

Note that this method only has a default implementation on Android R and above, and this method must still be overridden in order to run successfully on Android versions below R. LocationListenerCompat from the compat libraries may be used to avoid the need to override for older platforms.

<br />

| Parameters ||
|---|---|
| `provider` | `String`: the name of the location provider. This value cannot be `null`. <br /> |

### onProviderEnabled

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onProviderEnabled (String provider)
```

Called when a provider this listener is registered with becomes enabled.

Note that this method only has a default implementation on Android R and above, and this method must still be overridden in order to run successfully on Android versions below R. LocationListenerCompat from the compat libraries may be used to avoid the need to override for older platforms.

<br />

| Parameters ||
|---|---|
| `provider` | `String`: the name of the location provider. This value cannot be `null`. <br /> |

### onStatusChanged

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onStatusChanged (String provider, 
                int status, 
                Bundle extras)
```

<br />

**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 `https://developer.android.com/reference/android/location/LocationProvider#AVAILABLE` state.

Note that this method only has a default implementation on Android R and above, and this method must still be overridden in order to run successfully on Android versions below R. LocationListenerCompat from the compat libraries may be used to avoid the need to override for older platforms.

<br />

| Parameters ||
|---|---|
| `provider` | `String` <br /> |
| `status` | `int` <br /> |
| `extras` | `Bundle` <br /> |