StartActivityForResult | OnActivityResult Deprecated in Xamarin Android

Along with androidX support StartActivityForResult and OnActivityResult got dprecated inside Fragment. Here we can see the one of the alternate approach for this deprecated api's in xamarin android.

Below code snippet explains the handling the above mentioned deprecated API's:

In my previous post explained  Android Keystore based encryption and decryptionHow to implement Dependency injection in xamarin form using AutoFacReOrder the list items by drag and drop in xamarin androidCustom Image Gallery Control using Xamarin Form


Happy coding!!


  1. Hello,

    ActivityResultCallback class not found.
    However IActivityResultCallback interface exists
    Do I need to add any references?

  2. OK. The class is there at the end of the code.

  3. I'm upgrading one of my apps to android API 33 and I'm having some issues with this code that I can't resolve. The line " _activityResultLauncher = RegisterForActivityResult(new ActivityResultContracts.StartActivityForResult(), _activityResultCallback);" causes the IDE error "The name 'RegisterForActivityResult' does not exist in the current context". I'm using Visual Studio 2022 v17.3.6. I can't even test the code until I resolve this. Can anyone here help me?

    1. This comment has been removed by the author.

    2. Did you add required namespace, as suggested in this sample code