title: LocationSettingsRequest dialog to enable GPS - onActivityResult() skipped
body: <p>Part of my app requires location services, so if location is currently turned off, the app will prompt the user to enable it. <a href="https://developers.google.com/android/reference/com/google/android/gms/location/SettingsApi" rel="noreferrer">Here</a> is how I am doing it: (Also seen in <a href="https://stackoverflow.com/a/29872703/3558874">this</a> Stack Overflow answer)</p>
  
  <pre><code>LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
              .addLocationRequest(mLocationRequest);
  builder.setAlwaysShow(true);
  
  PendingResult&lt;LocationSettingsResult&gt; result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build());
  
  result.setResultCallback(new ResultCallback&lt;LocationSettingsResult&gt;() 
  {
       @Override
       public void onResult(LocationSettingsResult result) 
       {
           final Status status = result.getStatus();
           final LocationSettingsStates = result.getLocationSettingsStates();
           switch (status.getStatusCode()) 
           {
               case LocationSettingsStatusCodes.SUCCESS:
                   // All location settings are satisfied. The client can initialize location
                   // requests here.
                   ...
                   Log.d("onResult", "SUCCESS");
                   break;
               case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
                   // Location settings are not satisfied. But could be fixed by showing the user
                   // a dialog.
                   Log.d("onResult", "RESOLUTION_REQUIRED");
                   try 
                   {
                       // Show the dialog by calling startResolutionForResult(),
                       // and check the result in onActivityResult().
                       status.startResolutionForResult(OuterClass.this, REQUEST_LOCATION);
                   } 
                   catch (SendIntentException e) 
                   {
                       // Ignore the error.
                   }
                   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.
                   ...
                   Log.d("onResult", "UNAVAILABLE");
                   break;
           }
       }
   });
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      // This log is never called
      Log.d("onActivityResult()", Integer.toString(resultCode));
  
      final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
      switch (requestCode)
      {
          case REQUEST_LOCATION:
              switch (resultCode)
              {
                  case Activity.RESULT_OK:
                  {
                      // All required changes were successfully made
                      break;
                  }
                  case Activity.RESULT_CANCELED:
                  {
                      // The user was asked to change settings, but chose not to
                      break;
                  }
                  default:
                  {      
                      break;
                  }
              }
              break;
      }
  }
  </code></pre>
  
  <p>This code works well, however, <code>onActivityResult()</code> is always skipped. Whether or not the user presses <code>Yes</code>, <code>No</code>, or <code>back</code> from the <code>Dialog</code>, <code>onActivityResult()</code> doesn't run. </p>
  
  <p>I need Android to call <code>onActivityResult()</code> so if the user chooses not to turn on location services, I can handle it appropriately. </p>
  
  <p>Google's developer page (and the code above) explicitly says that <code>onActivityResult()</code> should be called. Anyone know why it's being skipped?</p>
  
  <p>I also don't know what the purpose of this line is:</p>
  
  <p><code>final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);</code></p>
  
  <p>Thanks!</p>
  
  <p>Edit: Basic information on the structure of my app:</p>
  
  <ul>
  <li>This code is contained within the <code>onResume()</code> method of a <code>Fragment</code> which implements <code>GoogleApiClient.ConnectionCallbacks</code>,                                                <code>GoogleApiClient.OnConnectionFailedListener</code>, and <code>LocationListener</code> to receive location updates. Example seen <a href="https://developer.android.com/intl/zh-CN/training/location/receive-location-updates.html" rel="noreferrer">here</a>.</li>
  <li>In <code>onLocationChanged()</code> the <code>Fragment</code> will have a custom <code>View</code> call <code>invalidate()</code> and re-draw itself with updated information.</li>
  </ul>