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 interface LocationListener

A listener for receiving locations from the FusedLocationProviderClient.

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

Public Method Summary

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

Public Methods

public abstract void onLocationChanged (Location location)

Invoked when a new Location is available. The location will generally be as fresh as possible given the parameters of the associated LocationRequest 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.