Passing values between Activities using MonoDroid - More Wally - Wallace B. McClure
in

MoreWally.com

Giving people what they want, More Wally. This is the technical and personal blog site of
Wallace B. (Wally) McClure.

This Blog

Syndication

News

Please goy buy 3-4 copies of my book on MonoTouch titled "Professional Android Programming with Mono for Android for .NET/C# Developers." They make great gifts all year round. Plus, I get about $.25 when you buy a copy.

Technical Sites

More Wally - Wallace B. McClure

This blog will have all kinds of posts about Wally McClure. In it, there will be tons of .NET and computer programming posts as well as Wally's views on life in general. As you might guess, this site and blog help you get More Wally in your life. What more could anyone want? iPhone, Android, MonoTouch, MonoDroid, Mobile, HTML5, .NET, ADO.NET, ASP.NET, AJAX, jQuery, jQuery Mobile, ASP.NET AJAX, and Windows Azure............follow me on twitter at Wally

Passing values between Activities using MonoDroid

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(thistypeof(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.

Published Feb 08 2011, 01:00 PM by wallym
Filed under: , , ,

Comments

No Comments
2006 - Wallace B. McClure
Powered by Community Server (Non-Commercial Edition), by Telligent Systems