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!!


5 comments:

  1. Hello,

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

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

    ReplyDelete
  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?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

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

      Delete