问题
Could someone please explain to me what is the difference between getExtras() and getBundleExtras()?
回答1:
getBundleExtra("String") gets a bundle named String.
getExtras() gets a bundle with all of the items placed into the array.
A bundle can be placed using a putExtra(Bundle, String tag) command, so the getBundleExtra() will return that value.
回答2:
Worth notting is the fact that getExtras() returns copy of the all items placed in the intent, its implementation looks like this:
4433 public Bundle getExtras() {
4434 return (mExtras != null)
4435 ? new Bundle(mExtras)
4436 : null;
4437 }
so its not a good idea to call intent.getExtras().putInt(...)
来源:https://stackoverflow.com/questions/9577024/what-is-the-difference-between-getextras-and-getbundleextras