Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The method signature of the android Activity method setResult is
public final void setResult (int resultCode)
The Xamarin Android binding changes this to
public void SetResult(Result resultCode)
This results in compatibilty issues if i'd like to use resultCode as an arbitrary integer resultCode. I'd like for example to return a page number as the resultCode. That's possible in my android code:
But fails for Xamarin with the error "Argument type 'int' is not assignable to parameter type 'Android.App.Result'".
Contrary to this the signature of the startActivityForResult is bound unchanged:
Android: public void startActivityForResult (Intent intent, int requestCode)
Xamarin: public virtual void StartActivityForResult(Intent intent, int requestCode);
I may change my Java implementation to use the setResult(Result resultCode, Intent data) method, but that's just a workaround.
This is inevitable. You need explicit cast to int.
If we change this signature from Result enum to int (which we will NOT do, because that brings API breakage), that causes other messes.
In early Mono for Android era from Novell, early developers converted ints to enums without covering "everything". It's partly done. There are some enums that are argurable to have been converted. Android.App.Result is typical "it's annoying without being converted to enum" "but some methods use resultCode/requestCode as int in common practice" "OK we apply best-appropriate one for each method" kind of enumification.
We could leave everything not-converted to enum, but that results in as annoying API as Java. There is not a LOT of required casts between ints and enums, so it is regarded as better than only-ints-based API.
This is by design.
You cannot change Java signature that Android framework expects.
I see the need to stay with the current binding to circumvent breaking any stuff.
Basically, searching for a solution for my problem, i'm able to use any integer value and passing this through the method by casting it to Result?
Especially for my case:
I haven't tried this yet, i'm not that far. But will this work? Is this the intended solution to satisfy the Xamarin binding?