In my android application I'm always using direct putExtra()
function of Intent
class to pass any number of value to new Activity
.
Like this:
Intent i = new Intent(this, MyActivity.class);
i.putExtra(ID_EXTRA1, "1");
i.putExtra(ID_EXTRA2, "111");
startActivity(i);
I know about Bundle
in Android and I have seen people are using Bundle
for passing values to new Activity
.
Like this:
Intent intent = new Intent(this, MyActivity.class);
Bundle extras = new Bundle();
extras.putString("EXTRA_USERNAME","my_username");
extras.putString("EXTRA_PASSWORD","my_password");
intent.putExtras(extras);
startActivity(intent);
Here I have 2 doubts.
Why should I use Bundle
if I can pass values to new Activity
by putting it directly to Intent
?
What are the advantages of using Bundle
instead of direct Intent
putExtra()
?