如题所述,bundle和intent都可以存放键值对数据,对数情况下直接用intent就好了,为什么还有intent+bundle这种搭配呢?
天蓬老师2017-05-16 13:37:37
一楼已经回答的很正确了,我只是贴出个源码来:
/**
* Add extended data to the intent. The name must include a package
* prefix, for example the app com.android.contacts would use names
* like "com.android.contacts.ShowAll".
*
* @param name The name of the extra data, with package prefix.
* @param value The String data value.
*
* @return Returns the same Intent object, for chaining multiple calls
* into a single statement.
*
* @see #putExtras
* @see #removeExtra
* @see #getStringExtra(String)
*/
public Intent putExtra(String name, String value) {
if (mExtras == null) {
mExtras = new Bundle();
}
mExtras.putString(name, value);
return this;
}