title: Why is onGeolocationPermissionsShowPrompt being called continuously?
body: <p>I have an app that uses a WebView where sites may request to use the device's geolocation. I have the following in my main activity:</p>
  
  <pre><code>public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) {
      m_geolocationCallback = null;
      m_geolocationOrigin = null;
  
      // If we don't have location permissions, we must request them first
      if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
          // Show rationale if necessary
          if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) {
  
              new AlertDialog.Builder(MainActivity.this)
                      .setMessage(getString(R.string.permission_location_rationale, origin))
                      .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialogInterface, int i) {
                              m_geolocationOrigin = origin;
                              m_geolocationCallback = callback;
                              ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
                          }
                      })
                      .show();
          }
          else {
              m_geolocationOrigin = origin;
              m_geolocationCallback = callback;
              ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION);
          }
      }
      // Otherwise just tell webview that permission has been granted
      else {
          callback.invoke(origin, true, false);
      }
  }
  </code></pre>
  
  <p>To handle the permission request result, <code>MainActivity</code> also has the following:</p>
  
  <pre><code>@Override
  public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
      switch (requestCode) {
          case PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION:
              // Permission granted
              if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                  if (m_geolocationCallback != null) {
                      m_geolocationCallback.invoke(m_geolocationOrigin, true, false);
                  }
              }
              // Permission denied
              else {
                  // In this case, the user checked "Don't ask again" and denied permission
                  if (Build.VERSION.SDK_INT &gt;= 23 &amp;&amp; !shouldShowRequestPermissionRationale(permissions[0])) {
                      Toast.makeText(this, R.string.permission_location_denied, Toast.LENGTH_LONG).show();
                  }
  
                  if (m_geolocationCallback != null) {
                      m_geolocationCallback.invoke(m_geolocationOrigin, false, false);
                  }
              }
              return;
      }
  }
  </code></pre>
  
  <p>The issue I'm running into is that whenever a site requests to use geolocation and I deny it (resulting in <code>invoke(origin, false false)</code> being called), the <code>onGeolocationPermissionsShowPrompt</code> method is called immediately and I am stuck in a loop of endlessly denying permission to the app.</p>
  
  <p>If I check "don't ask again" in the permission request, it works fine, but  I want to be able to ask the user for permission again at a later point in time.</p>
  
  <p>I've tried fixing this by changing my rejection callback invocation to
  <code>m_geolocationCallback.invoke(m_geolocationOrigin, false, true)</code>, but this does not produce the desired effect. This will prevent stop the continuous calls to <code>onGeolocationPermissionsShowPrompt</code>, but it also means that the given origin can no longer use geolocation even if permissions are later enabled, and I found no way to undo this (even by uninstalling/reinstalling the app).</p>
  
  <p>Any ideas on how to get around this issue?</p>