Question: =+ public void onClick(View view) { Intent i = new Intent(com.jfdimarzio.passingdata.SecondActivity); //---use putExtra() to add new name/value pairs--- i.putExtra(str1, This is a string); i.putExtra(age1, 25);
=+ public void onClick(View view) {
Intent i = new Intent("com.jfdimarzio.passingdata.SecondActivity");
//---use putExtra() to add new name/value pairs---
i.putExtra("str1", "This is a string");
i.putExtra("age1", 25);
//---use a Bundle object to add new name/values
// pairs---
Bundle extras = new Bundle();
extras.putString("str2", "This is another string");
extras.putInt("age2", 35);
//---attach the Bundle object to the Intent object---
i.putExtras(extras);
//---start the activity to get a result back---
startActivityForResult(i, 1);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
