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

This question may seem silly, but I know wana. When do we add the name of the activity to Intent.putExtra()? In one case, we add additional ones only with a bundle, and in the other case we pass it with the class name. I'm a little confused if we use Intent.putExtra(String, Bundle), have we already passed the name of the activity in the constructor Intentor not?

Thank you for your help!

+5
source share
3 answers

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

The first one adds the package as a value for the key that you provide. The package is simple - the value of the object.

/ . , .

Map:

Map.put(String key, Object value)

Map.putAll(Map anotherMap)
+13

- . Bundle, :

Bundle mBundle = new Bundle();
mBundle.put(key, value);

mIntent.putExtras(mBundle);

, , :

   Bundle extras = getIntent().getExtras();

Bundle :

extras.getString("myKey")
+1

All Articles