We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
SamplesLocation KitAndroid Sample Code

Android Sample Code

Content overview

Android Studio

The sample code provides a demo project that demonstrates how to call open APIs of Location Kit. Guided by the demo, you will learn how to:

  • Fused location: Request and stop requesting locations, set the mock location, obtain the location availability, and obtain the latest cached location.
  • Activity identification: Request and stop requesting activity identification and activity conversion.
  • Geofence: Add and remove geofences.
  • High-precision location: Request and stop requesting high-precision locations.
  • Indoor location: Request and stop requesting indoor locations.
  • Coordinate conversion: Convert WGS 84 coordinates into GCJ 02 coordinates.
Expand

Sample Code

Find It on Gitee

Find It on GitHub

Android Studio sample code (for Java and Kotlin)

Click here

Click here

NOTE

Before using the sample code, read the README file in the sample project carefully. Run the sample code only after you complete the following operations:

  1. Sign in to AppGallery Connect, download the agconnect-services.json file of your app, and copy the file to the app directory of the sample project.

  2. Open the build.gradle file in the sample project, and change the value of applicationId to your app package name.

Search
Enter a keyword.