Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
Passing values between Activities using MonoDroid - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, MonoTouch for iPhone, MonoDroid for Android, and Windows Azure.

News

Personal Blog

Work Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

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.
Posted: Feb 08 2011, 10:00 AM by Wallym | with no comments
Filed under: , , ,

Comments

No Comments