I know how to pass one string from one activity to another, but how would you do this for two strings "nameString" and "addressString"?
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addressString = address.getText().toString();
nameString = name.getText().toString();
Intent intent = new Intent(AddLocationActivity.this, MapsActivity.class);
intent.putExtra("address", addressString);
AddLocationActivity.this.startActivity(intent);
}
});
this way you can pass and retrive string from one activity to another activity
Intent intent = new Intent(AddLocationActivity.this, MapsActivity.class);
intent.putExtra("address", addressString);
intent.putExtra("string2", string2);
startActivity(intent);
retrive String to MapsActivity
Intent intent = getIntent();
String address = intent.getStringExtra("address");
String string2 intent.getStringExtra("string2");
Hope it will help you :)
Similar the way u passed 1st string u can pass 'n' number of strings via intent.
Intent intent = new Intent(AddLocationActivity.this, MapsActivity.class);
intent.putExtra("address", addressString);
intent.putExtra("string2", string2);
AddLocationActivity.this.startActivity(intent);
To pass:
add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addressString = address.getText().toString();
nameString = name.getText().toString();
Intent intent = new Intent(AddLocationActivity.this, MapsActivity.class);
intent.putExtra("name",nameString);
intent.putExtra("address", addressString);
AddLocationActivity.this.startActivity(intent);
}
});
}
To get:
Intent intent = getIntent();
String address = intent.getStringExtra("name");
String string2 intent.getStringExtra("address");