Possible Duplicate:
Passing data between activities in Android
I'm trying to pass a string from my main activity to another activity I have created. How would I do this?
Possible Duplicate:
Passing data between activities in Android
I'm trying to pass a string from my main activity to another activity I have created. How would I do this?
You would want to save your information into a bundle as an extras. Please see the code below
This would be for your First activity
String customerName = "Bob";
Bundle b = new Bundle();
Intent myIntent = new Intent(v.getContext(),work.class);
b.putString("Name", customerName);
myIntent.putExtras(b);
v.getContext().startActivity(myIntent);
Then to access the information in the other(Second) activity please see the code below
Bundle b = getIntent().getExtras();
String name = b.getString("customerName");
try this
FirstActivity
Bundle bundle = new Bundle();
bundle.putString("Your_KEY", "YOUR_STRING_VALUE");
Intent newIntent = new Intent(FirstActivity.this.getApplicationContext(), SecondActivity.class);
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
SecondActivity
Bundle bundle = SecondActivity.this.getIntent().getExtras();
String s = bundle.getString("Your_KEY");
In the secondActivity
public static String myName;
myName = "Miguel";
When you want to get it in the mainActivity:
String s1;
s1= secondActivity.myName;