My app contains a simple Fragment that is used to open external web pages, with:

```
Intent intent = new Intent(Intent.ACTION_VIEW, externalUrl); // Uri
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent chooserIntent = Intent.createChooser(intent, "Open URL...");
startActivityForResult(chooserIntent, RC_OPEN_URL);

```

And, when the result is returned (in my Fragment's `onActivityResult(...)`), the Fragment is popped off the backstack.

But, I'm now getting the new deprecation warning:

> 
> startActivityForResult(Intent,int) in Fragment has been deprecated
> 
> 
> 

I've read the corresponding [Getting a result from an activity](https://developer.android.com/training/basics/intents/result#java) documentation, but I'm not sure how to adapt the example they provide for my particular case.

I have discovered the **ActivityResultContracts.StartActivityForResult** class, but can't figure out how to pass my `chooserIntent` to it.

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 **registerForActivityResult()** method to open an external URL would be much appreciated.