Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass data from intent to an other intent

Tags:

android

I have two Intents and two Activitys.

I have in the first Intent an EditText.

I want to use the text in the EditText in the second intent and pass to the second intent

Intent myIntent = new Intent(mycurentActivity.this, secondActivity.class);
startActivity(myIntent); 

Thank you in advance

like image 452
User616263 Avatar asked Feb 03 '23 19:02

User616263


1 Answers

Your looking for Intent#putExtra(String, String).

Here is an example:

Intent myIntent = new Intent(mycurentActivity.this, secondActivity.class);
myIntent.putExtra("key", myEditText.Text.toString();
startActivity(myIntent); 

When your receiving the Intent you can extract it again:

String text = myIntent.getStringExtra("key");

(http://developer.android.com/reference/android/content/Intent.html#getStringExtra(java.lang.String))

like image 141
RoflcoptrException Avatar answered Feb 06 '23 14:02

RoflcoptrException