Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActivityResultLauncher and RegisterForActivityResult #289

Open
gmck opened this issue Mar 12, 2021 · 1 comment
Open

ActivityResultLauncher and RegisterForActivityResult #289

gmck opened this issue Mar 12, 2021 · 1 comment

Comments

@gmck
Copy link

gmck commented Mar 12, 2021

VS 16.10.0 P1.0

I recently upgraded Xamarin.AndroidX.AppCompat from 1.2.0.6 to 1.2.0.7
and Xamarin.AndroidX.Fragment from 1.2.5.4 to 1.3.0.1

This resulted in warnings re StartActivityForResult being deprecated in some of my Fragments. Then I noticed in my MainActivity (single Activity app) that there was one that didn't have a warning. This seems inconsistent, so I'm asking if that is expected and just a difference between Activity and Fragment or should it also be marked as obsolete/deprecated in Activity.

I reworked my code in the MainActivty to use the new ActivityResultLauncher and that worked ok. However, the IActivityResultCallback results in public void OnActivityResult(Java.Lang.Object p0) which leads to some pretty ugly code having to test and cast the p0 to whatever is needed before you can use it. The old way was at least readable!! The fragments now all use the new ActivityResultLauncher so they are ok as well.

I then tried a couple of variations of the other types of ActivtyResultContracts as tests in a test project. Some worked, some didn't. GetContent() works, but TakePicture() wouldn't return a bitmap. I think that is because of what was raised in Issue #288.

@gmck gmck added the packages label Mar 12, 2021
@JonnySKK
Copy link

JonnySKK commented Jun 9, 2021

This is still an issue 3 months later, the bindings need to be updated so that we don't have to use Java.Lang.Object p0 as a parameter on OnActivityResult. Casting isn't really a good solution

@jpobst jpobst removed the packages label Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants