Bug 11663 - base.Intent.GetIntExtra not getting the passed in int extra
Summary: base.Intent.GetIntExtra not getting the passed in int extra
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.6.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2013-04-08 22:27 UTC by Paul Johnson
Modified: 2013-04-08 22:37 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Paul Johnson 2013-04-08 22:27:29 UTC
The following piece of code comes from my app. The code worked fine with 4.6.1

(calling method)
btnView.Click += delegate
                List<string> ids = recsToView.Select(t => t.ToString()).ToList();
                Intent i = new Intent(this, typeof(infoRecord));
                i.PutExtra("list", ids.Count > 1 ? true : false);
                i.PutExtra("sex", baseInfo.sex);
                i.PutStringArrayListExtra("IDs", ids);
                if (ids.Count == 1)
                    i.PutExtra("ID", ids [0]);

(receiving activity)

bool isList = base.Intent.GetBooleanExtra("list", false); 
baseInfo.sex = base.Intent.GetBooleanExtra("sex", true); // male by default
baseInfo.ID = base.Intent.GetIntExtra("ID", -1);
bool all = base.Intent.GetBooleanExtra("all", false);

If I set a breakpoint at the StartActivity and check i, everything that I've said to put in there is in there. When I put a break point after bool all to check the contents, everything except baseInfo.ID has the correct value.

To check that I've not made a booboo with the name, I changed in the calling method 

i.PutExtra("ID", ids[0]);


i.PutExtra("Ident", ids[0]);

and in the receiving activity

int f = base.Intent.GetIntExtra("Ident", 0);

f shows as 0 despite it not leaving the calling method as being 0.
Comment 1 Paul Johnson 2013-04-08 22:37:18 UTC
It looks like the code should not have run in 4.6.1 correctly! The intent is correctly putting in the extra, but as a string whereas the read back needs to be an int. Casting ids[0] to Int32 solves the problem. 

Closing the bug. Move along. Nothing to see here ;)