Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between getExtras and getBundleExtras?

Could someone please explain to me what is the difference between getExtras() and getBundleExtras()?

like image 343
Toan Tran Van Avatar asked Mar 06 '12 02:03

Toan Tran Van


2 Answers

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.

like image 145
PearsonArtPhoto Avatar answered Oct 23 '22 01:10

PearsonArtPhoto


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(...)

like image 11
marcinj Avatar answered Oct 23 '22 01:10

marcinj