I have a sign-up form, and I have to pass all info filled in that form to another screen. I know how to display if there is one field, but in sign-up form there are multiple fields. so I want to know how to display all the info.
Asked
Active
Viewed 1,252 times
3 Answers
3
If you are launching a new activity, just create a Bundle
, add your values, and pass it into the new activity by attaching it to the Intent
you are using:
/*
* In your first Activity:
*/
String value = "something you want to pass along";
String anotherValue = "another something you would like to pass along";
Bundle bundle = new Bundle();
bundle.putString("value", value);
bundle.putString("another value", anotherValue);
// create your intent
intent.putExtra(bundle);
startActivity(intent);
/*
* Then in your second activity:
*/
Bundle bundle = this.getIntent().getExtras();
String value = bundle.getString("value");
String anotherValue = bundle.getString("another value");

burmat
- 2,548
- 1
- 23
- 28
1
To pass User data(multiple info) from one screen to another screen :
- Create a model for user with setter and getter method.
- make this class Serializable or Parcelable (Prefer) .
- Create object of user class and set all data using setter method.
Pass this object from one activity to another by using putSerializable.
Person mPerson = new Person();
mPerson.setAge(25); Intent mIntent = new Intent(Activity1.this, Activity2.class); Bundle mBundle = new Bundle(); mBundle.putSerializable(SER_KEY,mPerson); mIntent.putExtras(mBundle); startActivity(mIntent);
And get this object from activity 2 in on create methode.
Person mPerson = (Person)getIntent().getSerializableExtra(SER_KEY);
and SER_KEY will be same.
for more detail please go to this link:
http://www.easyinfogeek.com/2014/01/android-tutorial-two-methods-of-passing.html
I hope it will work for you.

Yogendra
- 4,817
- 1
- 28
- 21
0
You can make use of bundle for passing values from one screen to other