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

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core ReferencesLocation KitLocationLocationServices

LocationServices

CLASS info
Public class LocationServices
Location service. It provides location-related instances for you to obtain the location access point.

Public Method Summary

Return typeMethod name
static FusedLocationProviderClientgetFusedLocationProviderClient(Activity activity)
static FusedLocationProviderClientgetFusedLocationProviderClient(Context context)
static SettingsClientgetSettingsClient (Context context)
static SettingsClientgetSettingsClient (Activity activity)

Public Methods

Method
public static FusedLocationProviderClient getFusedLocationProviderClient(Activity activity)

This API is used to create a new FusedLocationProviderClient instance, which is used in an activity.

Notice:
If the input parameter is of the Activity type and an error occurs when the FusedLocationProviderClient instance is used to call the location service API, the app displays the interaction UI to prompt the user to handle the error. For example, if HMS Core (APK) is not in a version required for the location service, the app displays the UI to prompt the user to update HMS Core (APK).

Parameters

Parameter nameParameter desc
activityActivity.

Return

typedesc
FusedLocationProviderClientMain entry class for obtaining the location information.
Method
public static FusedLocationProviderClient getFusedLocationProviderClient(Context context)

This API is used to create a new FusedLocationProviderClient instance, which is used in the context. 

Notice:
If the input parameter is not of the Activity type and an error occurs when the FusedLocationProviderClient instance is used to call the location service API, the app only returns an error code but does not display the interaction UI to prompt the user to handle the error. For example, if HMS Core (APK) is not in a version required for the location service, the app returns the error code 907135003. In this case, the user needs to manually update HMS Core (APK). To show the update wizard, you are advised to pass a parameter of the Activity type instead of the Context type to create a Client instance.

Parameters

Parameter nameParameter desc
contextContext.

Return

typedesc
FusedLocationProviderClientMain entry class for obtaining the location information.
Method
public static SettingsClient getSettingsClient (Context context)

This API is used to create a new SettingsClient instance, which is used in the context. 

Notice:
If the input parameter is not of the Activity type and an error occurs when the SettingsClient instance is used to call the location service API, the app only returns an error code but does not display the interaction UI to prompt the user to handle the error. For example, if HMS Core (APK) is not in a version required for the location service, the app returns the error code 907135003. In this case, the user needs to manually update HMS Core (APK). To show the update wizard, you are advised to pass a parameter of the Activity type instead of the Context type to create a Client instance.

Parameters

Parameter nameParameter desc
contextContext.

Return

typedesc
SettingsClientEntry class for interacting with the location setting API.
Method
public static SettingsClient getSettingsClient (Activity activity)

This API is used to create a new SettingsClient instance, which is used in an activity.  

Notice:
If the input parameter is of the Activity type and an error occurs when the SettingsClient instance is used to call the location service API, the app displays the interaction UI to prompt the user to handle the error. For example, if HMS Core (APK) is not in a version required for the location service, the app displays the UI to prompt the user to update HMS Core (APK).

Parameters

Parameter nameParameter desc
activityActivity.

Return

typedesc
SettingsClientEntry class for interacting with the location setting API.
This page may contain third-party content. For details, click here.
Search in References
Enter a keyword.