LocationListener

  • LocationListener is an interface for receiving location updates from the FusedLocationProviderClient.

  • It's simpler to use than LocationCallback but receives batched locations as individual calls to onLocationChanged().

  • LocationListener does not provide location availability changes like LocationCallback.

  • The main method is onLocationChanged(), which is triggered when a new location is available.

  • Received locations might not always be the current location; checking the timestamp is recommended.

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.