如題所述,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;
}