Been doing some work in MonoDroid and found that I needed to pass a
user entered value from on Activity to another Activity in MonoDroid.
Here's how I did it.
In my sending Activity, I need to take some user user entered data and send it to my second activity. Here is the code:
string UserId = Convert.ToString(et.Text);
if (!String.IsNullOrEmpty(UserId))
{
Intent i = new Intent();
i.SetClass(this, typeof(CustomList));
i.AddFlags(ActivityFlags.NewTask);
i.PutExtra("TwitterId", UserId);
StartActivity(i);
}
In this code, I have called .PutExtra and passed it with a key. In
this case, I am passing a Twitter id. In the code that is receiving
the data, the code to retrieve the Twitter id is:
string twitterId = Intent.GetStringExtra("TwitterId");
The call to GetStringExtra() returns the value passed on the key.
As an FYI, my article on iPhone Programming with MonoTouch for
DevConnections magazine has been submitted and edited. I'm really
excited about this. It will coincide with my presentations at Mobile
Connections in Las Vegas in April, 2011. If you are coming to Mobile
Connections, please look me up while you are there, I'd love to meet you
and discuss mobile technologies.
In the meantime,
check out our book on MonoTouch.
The February edition of Visual Studio magazine is now online. In it, my article regarding MonoDroid, the implementation of C# and .NET for Android devices, is online. I can't thank Michael Desmond enough for the opportunity. Its fitting now that Android is the most popular smartphone platform. This article is available online at:
Along with the article, check out this short video that I did regarding MonoDroid on the Mac.
The article(s) were written based on MonoDroid Preview 9.1, so there are a few updates necessary, but I think this gets the basics out. I hope you enjoy the article(s).
And yes, we're still working on our book on MonoDroid. I've got a great author group and am excited about the book.
If you get a chance, come to AnDevCon in San Francisco in March. I'll be presenting on MonoDroid there.