Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Develop
Test
Publish
Monetize
Engage users
Device specifications
Resources
Skip to main content
This page describes common A3L Location APIs you can use in your app to support the primary functions of A3L Location described in Integrate A3L Location SDK.

Check settings

To get the current state of the location settings, call the A3LLocationSettingsResponse.getLocationSettingsStates() method. To make sure the system settings of a user’s device are in a state that allow location services to successfully perform location requests, use the checkLocationSettings() API. If the API determines that the required settings aren’t enabled on the device, you can choose to display a dialog to the user that guides them to enable the setting. Before you can check the system settings, you must create an A3LLocationSettingsRequest.Builder object that includes the A3LLocationRequest objects that your app uses. The following code shows an example of creating an A3LLocationSettingsRequest.Builder object with two location requests.
If your app uses Bluetooth Low Energy (BLE) for location, build your A3LLocationSettingsRequest.Builder object using the setNeedBle() method, as shown in the following code.
To check the system settings in your app, build the A3LLocationSettingsRequest object and pass it to the checkLocationSettings() method of the A3LSettingsClient class, as shown in the following example.
Add an on complete listener to the Task to handle the result. If the result throws an exception, your app can conditionally check the status codes to determine if the issue can be resolved. If the status code is RESOLUTION_REQUIRED, you can show a dialog to the user to ask them to allow the required setting. To do this, call ResolvableApiException.startResolutionForResult(), as shown in the following example.
For more information on status codes, see the API documentation for A3LLocationSettingsStatusCodes. The following example shows how to verify the results of startResolutionForResult() in the onActivityResult() method.

Get location availability

To determine if location data is available, use the getLocationAvailability() method. A successful Task result returns an A3LLocationAvailability object. To get a Boolean that indicates the likelihood that location data can be retrieved, use the isLocationAvailable() method. A true response doesn’t guarantee the location is available, but it indicates the location data is likely to be available. Similarly, a false response doesn’t confirm the location is unavailable, but it indicates the location data is likely to be unavailable. The following code shows an example of how to get location availability.
For Android devices without Google Play services, the getLocationAvailability() method only verifies whether the location is enabled or disabled.

Request continuous location updates

The requestLocationUpdates() method allows your app to repeatedly get location updates. If your app tracks users’ locations over time, this API can handle that use case. The requestLocationUpdates() method takes an A3LLocationRequest, an A3LLocationListener and a Looper. The API delivers results to the listener on the looper provided. If your app makes a location update request and your app previously made a location update request using the same listener, the new request replaces the previous one. The following code shows an example of how to request location updates.

Stop location updates

To stop location updates on a listener, use the removeLocationUpdates() method, as shown in the following code. The removeLocationUpdates() takes an A3lLocationListener object.
Last modified on September 13, 2023