Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent.putExtra(String,Bundle) vs Intent.putExtra(Bundle)

This question may sound stupid but I wana know When do we put activity name in Intent.putExtra()? In one case we are putting extra only with bundle and in other case we are passing it with class name. I am a little confused should we use Intent.putExtra(String, Bundle) we already have passed the activity name in Intent constructor or not?

Thanks for your help!

like image 479
Alfred James Avatar asked Aug 10 '12 10:08

Alfred James


1 Answers

I think you mean putExtra(String, Bundle) vs putExtras(Bundle) (with s).

The first adds the bundle as the value for the key you provide. The bundle is simple an object value.

The second adds all the key/value pairs from the provided bundle to the intent. In this case the content of the bundle will be added to the intent, not the bundle itself.

Think of them as in Map interface:

Map.put(String key, Object value)

vs

Map.putAll(Map anotherMap)
like image 187
helios Avatar answered Sep 19 '22 22:09

helios