Learn how to implement real-time data gathering and displaying for your Android apps.
Join the DZone community and get the full member experience. Real-time locating is a core function for many apps, allowing them to quickly and accurately locate users‘ real time locations. Location Kit enables apps to quickly obtain precise user locations and build up global locating capabilities, helping you implement personalized map display and interaction, as well as improve overall location-based service experience. This article demonstrates how to use Location Kit and Map Kit to implement the real-time locating capability in an app. An app can obtain and display a user’s real-time location on the map, especially when the app is launched for the first time. The map display changes in accordance to the user’s actual location. An app uses Location Kit to obtain a user’s real-time location and uses Map Kit to display the My Location button on the in-app map that the user can tap to determine their real-time location. 1. Register as a developer 2. Create an app, add the SHA-256 signing certificate fingerprint, enable Map Kit and Site Kit, and download the agconnect-services.json file of the app. 3. Configure the Android Studio project. (1) Copy the agconnect-services.json file to the app directory of the project. • Go to allprojects > repositories and configure the Maven repository address for the HMS Core SDK. • Go to buildscript > repositories and configure the Maven repository address for the HMS Core SDK. • If the agconnect-services.json file has been added to the app, go to buildscript > dependencies and add the AppGallery Connect plugin configuration. (2) Add build dependencies in the dependencies block. (3) Add the following configuration to the file header. (4) Copy the signing certificate generated in Generating a Signing Certificate to the app directory of your project, and configure the signing certificate in Android in the build.gradle file. (1) Compile a service to obtain a user’s real-time location. (2) Add a map in the activity to monitor a user’s real-time location. Tap My Location button to display the current location on the map Bind Location Kit to listen to location changing events Bind the activity to LocationServic Process the location changing events in the location changing listener Update map view You can use a mock location app to change your current location and see how the map view and My Location button alter accordingly. Opinions expressed by DZone contributors are their own.
Start
United States
dc3 United States software in english pdf Implement Real-time Locating in an Android App