Thursday, 14 July 2016

Android intent default value error



Please i am building an app and i keep having an error in the app
getIntExtra keeps returning the default value.
here is the code:

Intent i = new Intent(MonthGridActivity.this, DevotionListActivity.class);
int newPosition = position+1;
i.putExtra("monthId", newPosition);
startActivity(i);

public int getMonthId(){
int monthId;
Intent i = getIntent();
monthId = i.getIntExtra("monthId", 0);
return monthId;
}

I keep getting 0 as the return value. please help



No comments:

Post a Comment