Class A3LLocationProviderClient
- java.lang.Object
-
- com.amazon.A3L.location.A3LLocationProviderClient
-
public class A3LLocationProviderClient extends java.lang.Object
Provides abstraction over Google's FusedLocationProviderClient and Android's LocationManager . Holds the respective helper classes depending on the current service being used.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.android.gms.tasks.Task<android.location.Location>
getCurrentLocation(int priority, com.google.android.gms.tasks.CancellationToken cancellationToken)
Returns a single location fix representing the best estimate of the current location of the device.com.google.android.gms.tasks.Task<android.location.Location>
getCurrentLocation(A3LCurrentLocationRequest request, com.google.android.gms.tasks.CancellationToken cancellationToken)
Returns a single location fix representing the best estimate of the current location of the device.com.google.android.gms.tasks.Task<android.location.Location>
getLastLocation()
Returns the most recent historical location currently available.com.google.android.gms.tasks.Task<android.location.Location>
getLastLocation(A3LLastLocationRequest request)
Returns the most recent historical location currently available according to the given request.com.google.android.gms.tasks.Task<A3LLocationAvailability>
getLocationAvailability()
Returns the estimated availability of location data.com.google.android.gms.tasks.Task<java.lang.Void>
removeLocationUpdates(A3LLocationListener a3lLocationListener)
Removes all location updates for the given listener.com.google.android.gms.tasks.Task<java.lang.Void>
requestLocationUpdates(A3LLocationRequest a3lLocationRequest, A3LLocationListener a3lLocationListener, android.os.Looper looper)
Requests location updates with the given request and results delivered to the given listener on the specifiedLooper
.
-
-
-
Method Detail
-
getCurrentLocation
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<android.location.Location> getCurrentLocation(int priority, @Nullable com.google.android.gms.tasks.CancellationToken cancellationToken)
Returns a single location fix representing the best estimate of the current location of the device. This may return a cached location if a recent enough location fix exists, or may compute a fresh location. If unable to retrieve a current location fix, null will be returned.NOTE: The functionality across Devices with and without Play Services will be different. Devices without Play Services doesn't support
A3LPriority
, so theA3LPriority
set through this API would be ignored in these devices. In Devices with Play Services, theA3LPriority
will be supported as expected.- Parameters:
priority
- :A3LPriority
used to obtain location.cancellationToken
- : optionalCancellationToken
to cancel the request- Returns:
- Task: A
Task
that may be used to check for failure, success, completion, get result(Location) or respective exception.
-
getCurrentLocation
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<android.location.Location> getCurrentLocation(@NonNull A3LCurrentLocationRequest request, @Nullable com.google.android.gms.tasks.CancellationToken cancellationToken)
Returns a single location fix representing the best estimate of the current location of the device. This may return a historical location if a recent enough location fix exists, or may compute a fresh location. If unable to retrieve a current location fix, null will be returned.NOTE: The functionality across Devices with and without Play Services will be different. Devices without Play Services doesn't support
A3LCurrentLocationRequest
, so theA3LCurrentLocationRequest
set through this API would be ignored in these devices. In Devices with Play Services, theA3LCurrentLocationRequest
will be supported as expected.- Parameters:
request
- :A3LCurrentLocationRequest
with parameters detailing how to obtain the current location.cancellationToken
- : optionalCancellationToken
to cancel the request.- Returns:
- Task: A
Task
that may be used to check for failure, success, completion, get result(Location) or respective exception.
-
getLastLocation
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<android.location.Location> getLastLocation()
Returns the most recent historical location currently available. Will return null if no historical location is available. The historical location may be of an arbitrary age, so clients should check how old the location is to see if it suits their purposes.- Returns:
- Task: A
Task
that may be used to check for failure, success, completion, get result(Location) or respective exception.
-
getLastLocation
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<android.location.Location> getLastLocation(@NonNull A3LLastLocationRequest request)
Returns the most recent historical location currently available according to the given request. Will return null if no matching historical location is available.NOTE: The functionality across Devices with and without Play Services will be different. Devices without Play Services doesn't support
A3LLastLocationRequest
, so theA3LLastLocationRequest
set through this API would be ignored in these devices. In Devices with Play Services, theA3LLastLocationRequest
will be supported as expected.- Parameters:
request
- :A3LLastLocationRequest
with parameters detailing how to obtain the last location.- Returns:
- Task: A
Task
that may be used to check for failure, success, completion, get result(Location) or respective exception.
-
getLocationAvailability
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<A3LLocationAvailability> getLocationAvailability()
Returns the estimated availability of location data. IfA3LLocationAvailability.isLocationAvailable()
returns true then it is likely (but not guaranteed) that Location Provider APIs will be able to derive and return fresh location updates. IfA3LLocationAvailability.isLocationAvailable()
returns false, then it is likely (but not guaranteed) that Location Provider APIs will be unable to derive and return fresh location updates, though there may be historical locations available. NOTE: The functionality across Devices with and without Play Services will be different. Devices without Play Services will only check the current enabled/disabled state of location. In Devices with Play Services, it will work as expected.- Returns:
- Task: A
Task
that may be used to check for failure, success, completion, get result(estimated availability of location data) or respective exception.
-
requestLocationUpdates
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<java.lang.Void> requestLocationUpdates(@NonNull A3LLocationRequest a3lLocationRequest, @NonNull A3LLocationListener a3lLocationListener, @Nullable android.os.Looper looper) throws java.lang.IllegalStateException
Requests location updates with the given request and results delivered to the given listener on the specifiedLooper
. A previous request for location updates for the same listener will be replaced by this request. If the location request has a priority higher thanA3LPriority.PRIORITY_PASSIVE
, a wakelock may be held on the client's behalf while delivering locations(Note: This is not valid for devices without Google Play Services).Use
removeLocationUpdates(A3LLocationListener)
to stop location updates once no longer needed.Depending on the arguments passed in through the
A3LLocationRequest
, locations from the past may be delivered when the listener is first registered. Clients should ensure they are checking location timestamps appropriately if necessary.If the given Looper is null, the Looper associated with the calling thread will be used instead.
NOTE: The functionality across Devices with and without Play Services will be different. Devices without Play Services will only support MinUpdateIntervalMillis and MinUpdateDistanceMeters set through
A3LLocationRequest
. In Devices with Play Services, it will work as expected.- Parameters:
a3lLocationRequest
- :A3LLocationRequest
with parameters detailing how to obtain the location updates.a3lLocationListener
- : Listener to which location updates will be delivered.looper
- : Looper used by the listener.- Returns:
Task
- Throws:
java.lang.IllegalStateException
-
removeLocationUpdates
@NonNull @RequiresPermission(anyOf={"android.permission.ACCESS_COARSE_LOCATION","android.permission.ACCESS_FINE_LOCATION"}) public com.google.android.gms.tasks.Task<java.lang.Void> removeLocationUpdates(@NonNull A3LLocationListener a3lLocationListener)
Removes all location updates for the given listener.- Parameters:
a3lLocationListener
- :A3LLocationListener
from which location updates will be removed.- Returns:
- Task
-
-