Question: =+The preceding statements add two name/value pairs to the Intent object: one of type string and one of type integer. Besides using the putExtra() method,

=+The preceding statements add two name/value pairs to the Intent object: one of type string and one of type integer.

Besides using the putExtra() method, you can also create a Bundle object and then attach it using the putExtras() method. Think of a Bundle object as a dictionary object—it contains a set of name/value pairs. The following statements create a Bundle object and then add two name/value pairs to it. The Bundle object is then attached to the Intent object:

//---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);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Implementing Programming Languages Questions!