LocationListener
Stay organized with collections
Save and categorize content based on your preferences.
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eLocationListener\u003c/code\u003e is an interface for receiving location updates from the FusedLocationProviderClient.\u003c/p\u003e\n"],["\u003cp\u003eIt's simpler to use than \u003ccode\u003eLocationCallback\u003c/code\u003e but receives batched locations as individual calls to \u003ccode\u003eonLocationChanged()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLocationListener\u003c/code\u003e does not provide location availability changes like \u003ccode\u003eLocationCallback\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe main method is \u003ccode\u003eonLocationChanged()\u003c/code\u003e, which is triggered when a new location is available.\u003c/p\u003e\n"],["\u003cp\u003eReceived locations might not always be the current location; checking the timestamp is recommended.\u003c/p\u003e\n"]]],[],null,["# LocationListener\n\npublic interface **LocationListener** \nA listener for receiving locations from the [FusedLocationProviderClient](/android/reference/com/google/android/gms/location/FusedLocationProviderClient).\n\nThis differs from [LocationCallback](/android/reference/com/google/android/gms/location/LocationCallback)\nin that this interface is easier to implement and use, but will receive batches of location\n(in the event that a [LocationRequest](/android/reference/com/google/android/gms/location/LocationRequest)\nallows for batched locations) as multiple individual calls to [onLocationChanged(Location)](/android/reference/com/google/android/gms/location/LocationListener#onLocationChanged(android.location.Location)), and will not receive callbacks for changes to\n[LocationAvailability](/android/reference/com/google/android/gms/location/LocationAvailability).\nFor most simple location use cases clients will often find this interface easier to use than\n[LocationCallback](/android/reference/com/google/android/gms/location/LocationCallback). \n\n### Public Method Summary\n\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [onLocationChanged](/android/reference/com/google/android/gms/location/LocationListener#onLocationChanged(android.location.Location))([Location](//developer.android.com/reference/android/location/Location.html) location) Invoked when a new [Location](//developer.android.com/reference/android/location/Location.html) is available. |\n\nPublic Methods\n--------------\n\n#### public abstract void **onLocationChanged** ([Location](//developer.android.com/reference/android/location/Location.html) location)\n\nInvoked when a new [Location](//developer.android.com/reference/android/location/Location.html)\nis available. The location will generally be as fresh as possible given the parameters\nof the associated [LocationRequest](/android/reference/com/google/android/gms/location/LocationRequest)\nand the state of the device, but this does not imply that it will always represent the\ncurrent location. Clients should always check the timestamp associated with the\nlocation if necessary for their needs."]]