title: Google maps permission to use the location failed
body: <p>I am asking for permissions, when the app is firstly installed using this code: </p>
  
  <pre><code> private void getLocationPermission() {
      Log.d(TAG, "getLocationPermission: getting location permissions");
      String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION,
              Manifest.permission.ACCESS_COARSE_LOCATION};
  
      if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
              FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
          if (ContextCompat.checkSelfPermission(this.getApplicationContext(),
                  COURSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
              mLocationPermissionsGranted = true;
              initMap();
              getDeviceLocation();
          } else {
              ActivityCompat.requestPermissions(this,
                      permissions,
                      LOCATION_PERMISSION_REQUEST_CODE);
          }
      } else {
          ActivityCompat.requestPermissions(this,
                  permissions,
                  LOCATION_PERMISSION_REQUEST_CODE);
      }
  }
  
  @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      Log.d(TAG, "onRequestPermissionsResult: called.");
      mLocationPermissionsGranted = false;
  
      switch (requestCode) {
          case LOCATION_PERMISSION_REQUEST_CODE: {
              if (grantResults.length &gt; 0) {
                  for (int i = 0; i &lt; grantResults.length; i++) {
                      if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
                          mLocationPermissionsGranted = false;
                          Log.d(TAG, "onRequestPermissionsResult: permission failed");
                          return;
                      }
                  }
                  Log.d(TAG, "onRequestPermissionsResult: permission granted");
                  mLocationPermissionsGranted = true;
                  getDeviceLocation();
                  //initialize our map
                  initMap();
              }
          }
      }
  }
  </code></pre>
  
  <p>So, when it gets checked by <code>getLocationPermission</code> that I do not have the permission to use the location, the <code>permission alert dialog</code> pops up, and asks me if I <code>allow</code> it or not. But, if I press the <code>allow</code> option, in my <code>logcat</code> I get message <code>onRequestPermissionsResult: permission failed</code>, as, according to my code, would mean I did not give access. The weird part is that if I reopen the activity using the map, the permissions work fine.</p>