title: How to check if Location Settings have failed when changed
body: <p>I am creating a locationrequest object of the LocationRequest class whose methods are used to determine the level of location accuracy my app needs.</p>
  
  <pre><code>private LocationRequest mLocationRequest;
  mLocationRequest = new LocationRequest();
  mLocationRequest.setInterval(2000);
  mLocationRequest.setFastestInterval(1000);
  mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
  </code></pre>
  
  <p>and then creating a LocationSettingsRequest.Builder object and then adding the location request object to it.</p>
  
  <pre><code>new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
  </code></pre>
  
  <p>According to the Android documentation, SettingsClient is responsible to ensure that the device's system settings are properly configured for the app's location needs.</p>
  
  <pre><code>SettingsClient client = LocationServices.getSettingsClient(this);
  Task&lt;LocationSettingsResponse&gt; task = 
  client.checkLocationSettings(builder.build());
  </code></pre>
  
  <p>The documentation states that when the Task completes, the client can check the location settings by looking at the status code from the LocationSettingsResponse object.</p>
  
  <pre><code>task.addOnCompleteListener(new OnCompleteListener&lt;LocationSettingsResponse&gt;() 
  {
              @Override
              public void onComplete(Task&lt;LocationSettingsResponse&gt; task) {
                  try {
                      LocationSettingsResponse response = task.getResult(ApiException.class);
  
                      // All location settings are satisfied. The client can initialize location
                      // requests here.
                  } catch (ApiException exception) {
                      Log.v(" Failed ", String.valueOf(exception.getStatusCode()));
  
                      switch (exception.getStatusCode()) {
  
                          case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                              // Location settings are not satisfied. But could be fixed by showing the
                              // user a dialog.
                              // Cast to a resolvable exception.
                              ResolvableApiException resolvable = (ResolvableApiException) exception;
                              // Show the dialog by calling startResolutionForResult(),
                              // and check the result in onActivityResult().
                              try {
                                  resolvable.startResolutionForResult(
                                          MapsActivity.this,
                                          REQUEST_CHECK_SETTINGS);
                              } catch (IntentSender.SendIntentException e) {
                                  e.printStackTrace();
                              }
                              break;
                          case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
                              // Location settings are not satisfied. However, we have no way to fix the
                              // settings so we won't show the dialog.
                              break;
                      }
                  }
              }
          });
  </code></pre>
  
  <p>According to from what I understand the code above checks if the task on completed was able to accept the location settings that were changed when we did </p>
  
  <p>The documentation also states that if the status code is RESOLUTION_REQUIRED, the client can call startResolutionForResult(Activity, int) to bring up a dialog, asking for the user's permission to modify the location settings to satisfy those requests. </p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
      switch (requestCode) {
          case REQUEST_CHECK_SETTINGS:
              switch (resultCode) {
                  case Activity.RESULT_OK:
                      // All required changes were successfully made
                      Toast.makeText(getBaseContext(), "All good", Toast.LENGTH_SHORT).show();
                      break;
                  case Activity.RESULT_CANCELED:
                      // The user was asked to change settings, but chose not to
                      break;
                  default:
                      break;
              }
              break;
      }
  }
  </code></pre>
  
  <p>I want this scenario to occur wherein I can test if RESOLUTION_REQUIRED was the status code and I can prompt the user to change it. Can anyone please tell me what can I do in the code or my phone setting to test this scenario. </p>