Note putExtras replicates the incoming bundle rather than referencing it So if you were to change the incoming bundle you wouldnt be changing the bundle inside the intent

You can use a number of methods to add fundamental types to the bundle. Here are some of the methods that add simple data types to the extra data:

putExtra(String name, boolean value); putExtra(String name, int value); putExtra(String name, double value); putExtra(String name, String value);

And here are some not-so-simple extras:

//simple array support putExtra(String name, int[] values); putExtra(String name, float[] values);

//Serializable objects putExtra(String name, Serializable value);

//Parcelable support putExtra(String name, Parcelable value);

//Add another bundle at a given key //Bundles in bundles putExtra(String name, Bundle value);

//Add bundles from another intent //copy of bundles putExtra(String name, Intent anotherlntent); //Explicit Array List support putIntegerArrayListExtra(String name, ArrayList arrayList); putParcelableArrayListExtra(String name, ArrayList arrayList); putStringArrayListExtra(String name, ArrayList arrayList);

On the receiving side, equivalent methods starting with get retrieve information from the extra bundle based on key names.

The Intent class defines extra key strings that go with certain actions. You can discover a number of these extra-information key constants at reference/android/content/Intent.html#EXTRA_ALARM_COUNT.

Let us consider a couple of example extras that involve sending e-mails:

EXTRA_EMAIL: You will use this string key to hold a set of e-mail addresses. The value of the key is android.intent.extra.EMAIL. It should point to a string array of textual e-mail addresses.

EXTRA_SUBJECT: You will use this key to hold the subject of an e-mail message. The value of the key is android.intent.extra.SUBJECT. The key should point to a string of subject.

0 0

Post a comment