I have total 3 activites. I pass the data from the first activity like this:
Intent i = new Intent(getApplicationContext(), History.class);
i.putExtra("day", mDay);
i.putExtra("month", mMonth+1);
i.putExtra("year", mYear);
startActivity(i);
get the data:
Bundle extras = getIntent().getExtras();
if(extras !=null) { .......
now I pass the data from the second activity:
Intent i = new Intent(getApplicationContext(), History.class);
i.putExtra("Hday", mDay);
i.putExtra("Hmonth", mMonth);
i.putExtra("Hyear", mYear);
startActivity(i);
and get the data from the second activity:
Bundle extras2 = getIntent().getExtras();
if(extras2 !=null) {
So, I have extras to get the data from the first activity, and extras2 to get the data from the second activity. But when I pass the data from any activity both extras are not null!
What have I done wrong?
The problem is that your third activity has no way of knowing which activity sent the bundle. You need to add a field that identifies what type of bundle this is so you can process accordingly. For instance, in activity 1:
Then in 3rd activity: