LocationListener

  • LocationListener is an interface for receiving locations from the FusedLocationProviderClient.

  • It is easier to implement and use compared to LocationCallback for most simple location use cases.

  • Unlike LocationCallback, it receives batched locations as multiple individual calls to onLocationChanged and does not receive callbacks for LocationAvailability changes.

  • The onLocationChanged method is invoked when a new Location is available.

public interfaceLocationListener

A listener for receiving locations from theFusedLocationProviderClient.

This differs fromLocationCallback in that this interface is easier to implement and use, but will receive batches of location (in the event that aLocationRequest allows for batched locations) as multiple individual calls to onLocationChanged(Location), and will not receive callbacks for changes toLocationAvailability. For most simple location use cases clients will often find this interface easier to use thanLocationCallback.

Public Method Summary

abstract void
onLocationChanged(Location location)
Invoked when a newLocation is available.

Public Methods

public abstract voidonLocationChanged(Location location)

Invoked when a newLocation is available. The location will generally be as fresh as possible given the parameters of the associatedLocationRequest and the state of the device, but this does not imply that it will always represent the current location. Clients should always check the timestamp associated with the location if necessary for their needs.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-10-31 UTC.