This sample app demonstrates how to integrate AWS Location Service with an Android application using Amazon Cognito for authentication and tracking location updates in real time. It showcases the usage of Amazon Location Service's Tracking and Authentication SDKs to authenticate users and track their location on a map.
Additional documentation for this sample application is available from the Amazon Location Service documentation website.
- Tracking SDK: Amazon Location Service Tracking SDK
- Auth SDK: Amazon Location Service Authentication SDK
- Clone this repository to your local machine.
- Open the
AmazonSampleSDKApp
project in Android Studio. - Build and run the app on your Android device or emulator.
- Open
template.properties
file - Copy the content of
template.properties
file to a new file namedcustom.properties
- Configure AWS credentials in the app using the following steps:
- Step 1. Configure custom.properties: Fill in the required values in the
custom.properties
file to configure the AWS credentials. (Refer to the Configuration section for details) - Step 2. Configure inside app: Upon launching the app, navigate to the Config tab and click on the Sign in button. This will open a dialogue in which you enter your AWS Identity Pool ID, Map Name, and Tracker Name to configure the AWS credentials.
Create a custom.properties
file in your project directory and input the following lines, replacing placeholders with actual values:
MQTT_END_POINT=xxxxxxxxxxxxx-xxx.xxx.<MY-AWS-REGION>.amazonaws.com
POLICY_NAME=xxxxxxxxx
GEOFENCE_COLLECTION_NAME=xxxxxxxxxxxxxxxxx
TOPIC_TRACKER=xxxxxxxxxx
- MQTT_END_POINT: The WebSocket URL in MQTT Amazon Location Service.
- POLICY_NAME: The name of the IoT policy in Amazon Location Service.
- TOPIC_TRACKER: The name of the topic in MQTT Amazon Location Service.
- GEOFENCE_COLLECTION_NAME: The Amazon Resource Name of your geofence collection in Amazon Location Service.
These values are used to configure the app's connection to AWS services.
The app provides options to filter location tracking data based on time, distance, and accuracy:
- Time Filter: If enabled, location updates are sent only after the specified time interval has passed.
- Distance Filter: If enabled, location updates are sent only after moving a specified distance from the last reported location.
- Accuracy Filter: If enabled, location updates are filtered based on the specified accuracy level.
These filters help in optimizing the location tracking to suit different use cases and requirements.
-
To run the Automated UI test case, add the below properties to the
custom.properties
file created above inside the Configuration section.DEFAULT_TRACKER_NAME=xxxxxxx TEST_POOL_ID=<MY-AWS-REGION>:xxxxxxxxxxxxxxxxxxxxxxxxxx TEST_MAP_STYLE=xxxxxxxxxxxxxxxxxxx TEST_API_KEY=xx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx TEST_API_KEY_REGION=<MY-AWS-API_KEY_REGION>
- DEFAULT_TRACKER_NAME: The name of the tracker resource in Amazon Location Service used for tracking location updates.
- TEST_POOL_ID: Your AWS Cognito Identity Pool ID used for authenticating users.
- TEST_MAP_STYLE: The style name of the map resource in the Amazon Location Service you want to use to display the map.
- TEST_API_KEY: Your api key used for authenticating users to access maps, routes and places.
- TEST_API_KEY_REGION: Your api key AWS region.
-
Create and run the emulator of the latest Android version or plug in the real Android device.
-
Now open the
DefaultFlowSuite
file located inside theandroidTest
directory and click on the play button.
With the above steps, you can run the automated UI test cases.