title: Java solution for "startActivityForResult(Intent,int) in Fragment has been deprecated" when opening external URL?
body: <p>My app contains a simple Fragment that is used to open external web pages, with:</p>
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW, externalUrl); // Uri
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  Intent chooserIntent = Intent.createChooser(intent, &quot;Open URL...&quot;);
  startActivityForResult(chooserIntent, RC_OPEN_URL);
  </code></pre>
  <p>And, when the result is returned (in my Fragment's <code>onActivityResult(...)</code>), the Fragment is popped off the backstack.</p>
  <p>But, I'm now getting the new deprecation warning:</p>
  <blockquote>
  <p>startActivityForResult(Intent,int) in Fragment has been deprecated</p>
  </blockquote>
  <p>I've read the corresponding <a href="https://developer.android.com/training/basics/intents/result#java" rel="noreferrer">Getting a result from an activity</a> documentation, but I'm not sure how to adapt the example they provide for my particular case.</p>
  <p>I have discovered the <strong>ActivityResultContracts.StartActivityForResult</strong> class, but can't figure out how to pass my <code>chooserIntent</code> to it.</p>
  <p>All the online examples for the class seem to be in Kotlin and I've not had any joy trying to decompile them to Java. So a Java example of how to use the new <strong>registerForActivityResult()</strong> method to open an external URL would be much appreciated.</p>