Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
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.
HMS Core
| Class Info |
|---|
| public class SettingsClient Location setting check class. An instance of this class will be returned when the getSettingsClient(Context context) or getSettingsClient(Activity activity) method in the LocationServices class is called. |
- SettingsClient settingsClient = LocationServices.getSettingsClient(this);
- LocationRequest locationRequest = new LocationRequest();
- LocationSettingsRequest.Builder builder =
- new LocationSettingsRequest.Builder().addLocationRequest(locationRequest)
- .setAlwaysShow(false)
- .setNeedBle(false);
- settingsClient.checkLocationSettings(builder.build())
- .addOnCompleteListener(new OnCompleteListener<LocationSettingsResponse>() {
- @Override
- public void onComplete(Task<LocationSettingsResponse> task) {
- if (task != null && task.isSuccessful()) {
- LocationSettingsResponse response = task.getResult();
- if (response == null) {
- return;
- }
- LocationSettingsStates locationSettingsStates = response.getLocationSettingsStates();
- // TODO: Process the result returned when the API call is successful.
- }
- }
- })
- .addOnFailureListener(new OnFailureListener() {
- @Override
- public void onFailure(Exception e) {
- Log.i(TAG, "checkLocationSetting onFailure:" + e.getMessage());
- }
- });
- val settingsClient = LocationServices.getSettingsClient(this)
- val locationRequest = LocationRequest()
- val builder =
- LocationSettingsRequest.Builder().addLocationRequest(locationRequest)
- .setAlwaysShow(false)
- .setNeedBle(false)
- settingsClient.checkLocationSettings(builder.build())
- .addOnCompleteListener { task ->
- if (task != null && task.isSuccessful) {
- val response = task.result ?: return@addOnCompleteListener
- val locationSettingsStates =
- response!!.locationSettingsStates
- // TODO: Process the result returned when the API call is successful.
- }
- }
- .addOnFailureListener { e ->
- Log.i(TAG, "checkLocationSetting onFailure:" + e.message)
- }
| Qualifier and Type | Method Name and Description |
|---|---|
| checkLocationSettings(LocationSettingsRequest locationSettingsRequest) Checks whether relevant location settings are valid. | |
| Task<Void> | setLogConfig(LogConfig logConfig) Sets whether to enable log recording. |
| Method |
|---|
| public Task<LocationSettingsResponse> checkLocationSettings(LocationSettingsRequest locationSettingsRequest) Checks whether relevant location settings are valid. To use this method, you must first create a LocationSettingsRequest.Builder class and add the LocationRequest object that will be used by your app. LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest); Then, call the checkLocationSettings method. Task<LocationSettingsResponse> result = LocationServices.getSettingsClient(this).checkLocationSettings(builder.build()); Your app can call getLocationSettingsStates() to obtain the current status of relevant location settings. |
Parameters
| Name | Description |
|---|---|
| locationSettingsRequest | Request object related to location settings. |
Returns
| Type | Description |
|---|---|
| Task execution result. You can add listeners using addOnSuccessListener() and addOnFailureListener() to obtain the current method execution result. If the result is failure, convert the thrown Exception object into an ApiException object, and then call the getStatusCode() method of the ApiException object to obtain the result code. If the result code is 6, the task execution failed. (You can instruct users to modify the location settings to solve the problem.) |
| Method |
|---|
| public Task<Void> setLogConfig(LogConfig logConfig) Sets whether to enable log recording. To use this method, create SettingsClient settingsClient = LocationServices.getSettingsClient(this), create LogConfig logConfig = new LogConfig(), set parameters for logConfig, and call the setLogConfig() method of SettingsClient to enable log recording. |
Parameters
| Name | Description |
|---|---|
| logConfig | Request parameters for log recording. |
Returns
| Type | Description |
|---|---|
| Task<Void> | Task execution result. You can add listeners using addOnFailureListener() to obtain the current method execution result. If the result is failure, call the getMessage() method of the Exception object to obtain the failure reason. If no error information is returned, log recording is enabled successfully. |
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.