The Location SDK provides a simple set of location-based services (LBS) interfaces. You can use the location APIs to obtain location results.
The Location component supports two integration methods: native AAR mode and component mode.
Prerequisites
If you use the native AAR method for integration, you must first complete the steps in Add mPaaS to your project.
If you use the component-based method for integration, you must first complete the component mode Flow.
Add the SDK
native AAR mode
Use Component Management (AAR) to install the Location component in your project. For more information, see AAR Component Management.
component mode
Install the Location component in your Portal and Bundle projects from Component Management. For more information, see Manage component dependencies.
Request an Amap key
Before you can use LBS, you must request an account and obtain a location key from the Amap Open Platform. An example of a key is shown below:

Configure AndroidManifest
In the AndroidManifest.xml file, add the Amap location key and the Amap location service.
<!--Amap location Key-->
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="Enter your Amap key" />
<!--Amap location Service-->
<service android:name="com.amap.api.location.APSService"></service>Starting from version 10.1.68.18, the automatic check-in feature of the Location component is disabled by default. To enable automatic check-in, manually add the following configuration to the AndroidManifest.xml file:
<meta-data android:name="com.mpaas.lbs.autoCheckIn" android:value="true" />API reference
Call the location feature
By default, the location is resolved to the district or county level. For street-level details, see other related APIs.
LBSLocationManagerProxy.getInstance().requestLocationUpdates(MainActivity.this, new LBSLocationListener() {
@Override
public void onLocationUpdate(LBSLocation lbsLocation) {
Toast.makeText(MainActivity.this, "lbsLocation is " + lbsLocation.getAddress(), Toast.LENGTH_LONG).show();
}
@Override
public void onLocationFailed(int i) {
Toast.makeText(MainActivity.this,
"onLocationFailed" + i, Toast.LENGTH_SHORT).show();
}
});Other related APIs
/**
* Registers location updates. The location is accurate to the district level.
*/
public void requestLocationUpdates(Context context, LBSLocationListener locationListener)
/**
* Registers location updates. Use this API if you need street-level accuracy.
* gpsEnable: false indicates district-level accuracy. true indicates street-level accuracy, which provides higher precision but consumes more resources.
* miniInterval: The location update interval. For example, LBSLocationManagerProxy.DEFAULT_LOCATION_INTERVAL.
* overtime: The location timeout period. For example, LBSLocationManagerProxy.LOCATION_TIME_OUT.
* isNeedAddress: true indicates that reverse geocoding is required. false indicates that only the latitude and longitude are required.
* bizType: The business type. Set to null.
*/
public void doRequestLocationUpdates(Context context, boolean gpsEnable, LBSLocationListener locationListener, long miniInterval, long overtime, boolean isNeedAddress, String bizType)
// Removes the callback for location registration.
public void removeUpdates(Context context, LBSLocationListener listener)
// Gets the last known successful location.
public LBSLocation getLastKnownLocation(Context context)