title: Activity Result APIs is not returning callback for RequestPermission Contract
body: <p>I am not getting permission result callback on Activity Result api as mentioned in the doc.</p>
  
  <p><a href="https://developer.android.com/training/basics/intents/result#kotlin" rel="nofollow noreferrer">Getting a result from an activity</a></p>
  
  <p>I am using <code>implementation "androidx.activity:activity-ktx:1.2.0-alpha02"</code></p>
  
  <p><strong>Here is the api code :</strong></p>
  
  <pre><code>/**
   * An {@link ActivityResultContract} to {@link Activity#requestPermissions request a permission}
   */
  public static class RequestPermission extends ActivityResultContract&lt;String, Boolean&gt; {
  
      @NonNull
      @Override
      public Intent createIntent(@NonNull String input) {
          return new Intent(ACTION_REQUEST_PERMISSIONS)
                  .putExtra(EXTRA_PERMISSIONS, new String[] { input });
      }
  
      @NonNull
      @Override
      public Boolean parseResult(int resultCode, @Nullable Intent intent) {
          if (resultCode != Activity.RESULT_OK) return false;
          if (intent == null) return false;
          int[] grantResults = intent.getIntArrayExtra(EXTRA_PERMISSION_GRANT_RESULTS);
          if (grantResults == null) return false;
          return grantResults[0] == PackageManager.PERMISSION_GRANTED;
      }
  }
  </code></pre>
  
  <p><strong>Here is my implementation :</strong></p>
  
  <pre><code>private val permission = prepareCall(object : ActivityResultContracts.RequestPermission() {
      override fun createIntent(input: String): Intent {
          if (shouldShowRequestPermissionRationale(input)) {
              Toast.makeText(
                  this@MainActivity,
                  "shouldShowRequestPermissionRationale - true",
                  Toast.LENGTH_SHORT
              ).show()
              // case 2
          } else {
              Toast.makeText(
                  this@MainActivity,
                  "shouldShowRequestPermissionRationale - false",
                  Toast.LENGTH_SHORT
              ).show()
              // case 1 and 3
          }
          return super.createIntent(input)
      }
  
      override fun parseResult(resultCode: Int, intent: Intent?): Boolean {
          val t = super.parseResult(resultCode, intent)
          Toast.makeText(this@MainActivity, "parseResult $t", Toast.LENGTH_SHORT).show()
          return t
      }
  }) {
      Log.d("permission granted?", "$it")
  }
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      button.setOnClickListener {
          permission(android.Manifest.permission.CAMERA)
      }
  }
  </code></pre>
  
  <p>As per doc, I should be getting callback inside <code>ActivityResultCallback</code> but after backtracking I figure in my case, it even does not call <code>ParseResult</code> function. Though I am still receiving callback inside <code>onRequestPermissionsResult</code> function.</p>
  
  <p>So, am I doing something wrong ?</p>
  
  <p>Please refer <a href="https://developer.android.com/training/basics/intents/result#kotlin" rel="nofollow noreferrer">Getting a result from an activity</a> to understand this api.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I was able to get the callback after extending my activity with <code>ComponentActivity</code> but again, if the permission is already given then app wont receive callback, is there any way to directly handle here? I don't wanna check self permission.</p>
  
  <p>Sample demo code - <a href="https://github.com/tasneembohra/ActivityResultApiDemo" rel="nofollow noreferrer">https://github.com/tasneembohra/ActivityResultApiDemo</a></p>