Now you can Subscribe using RSS

Submit your Email

Saturday

Difference between Bundle and putExtra of Intent

Vishal Shrestha
Using bundle will create negligible difference in your application. Using a bundle is slightly more manageable and clear. When you are using a putExtra, you are using a bundle anyway, you can see here that Intent store data passed through putExtra internally as Bundle-
public Intent putExtra(String name, String value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putString(name, value);
    return this;
}
You are using bundle anyway, there is no alternative.
Well there's a very stupid alternative of using shared preferences.
The only time i have found Bundles more useful is when i have a bunch of variables that i need to pass between multiple activities. I can easily pass around the same bundle every time instead of passing around single values.

Vishal Shrestha / Author & Founder

A developer by profession, a born Adventurer. I mainly do Android but like to get my hands dirty with web development and a little bit of Python. I would't rather go on a Trek than a party and you can find me having a few rounds with the heavy bag to let out the steam ;)

For Business info : My Portfolio Site.

0 comments:

Post a Comment

Coprights @ 2017 | The Code City by Vishal Shrestha Vishal Shrestha