Search code examples
androidandroid-intentextra

Why am i not able to get Extras from the intent this way?


In the previous Activity i did this:

int entryId = 10;
intent.putExtra("entry_id", entryId);

then in the resultant Activity

First i tried this:

entry_id = this.getIntent().getExtras().getInt("entry_id");

it always gives me the default value 0

But i changed to this:

entry_id = this.getIntent().getIntExtra("entry_id", 1);

it gives the correct value (10).

why is it so?


Solution

  • Chanage entry_Id to entry_id in your first case.