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
Get step-by-step solutions from verified subject matter experts
