Kugan Kumar Kugan Kumar - 1 year ago 321
Android Question

What is difference between bundle.getString() and intent.getStringExtra()?

What is difference between bundle.getString() and intent.getStringExtra() ?

I am new to android, still learning, just curios to know the differences between both.

thanks in advance

Answer Source

With Intent.getStringExtra() we get the Bundled string data directly from the intent object.

To be precise, we can get the string data from intent with Bundle object like this:

// Call from received activity or component.
Bundle extras = getIntent().getExtras();
String value1 = extras.getString("OUR_TEXT_KEY");

So, Bundle.getString() is the same as Intent.getExtras.getString(). Bundle object is within the Intent.

Please read about Intent.getExtras().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download