Kugan Kumar Kugan Kumar - 4 months ago 56
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

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