title: Requesting permissions in Android
body: <p>I am trying to request 2 permissions when the app opens up. It works fine, but when the user selects never ask again, a toast message should be displayed once. The toast message keeps on coming up repeatedly and does not stop. I cannot figure out the reason for this.</p>
  <pre><code>public void checkPermission(final Context context) {
      if(ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
          if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.READ_EXTERNAL_STORAGE) || ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, Manifest.permission.CAMERA)) {
              ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}, 1);
          }
          else {
              ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA}, 1);
          }
      }
  }
  
  @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED &amp;&amp; grantResults[1] == PackageManager.PERMISSION_GRANTED) {
          Toast.makeText(this, &quot;Both permissions granted&quot;, Toast.LENGTH_SHORT).show();
      } else {
          checkPermission(this);
      }
      if (requestCode == 1) {
          for (int i = 0, len = permissions.length; i &lt; len; i++) {
              String permission = permissions[i];
              boolean showRationale;
              if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                  showRationale = shouldShowRequestPermissionRationale(permission);
                  if (!showRationale) {
                      Toast.makeText(this, &quot;Denied&quot;, Toast.LENGTH_SHORT).show();
                  }
              }
          }
      }
      }
  </code></pre>
  <p>Above is the code that checks for permissions.</p>
  <p>I would like to know why the toast message never stops popping up.</p>