Passing Data From Two Activities To A Third
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);
Solution 1:
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:
Intent i = newIntent(getApplicationContext(), History.class);
i.putExtra("activity", (int)1);
i.putExtra("day", mDay);
i.putExtra("month", mMonth+1);
i.putExtra("year", mYear);
startActivity(i);
Then in 3rd activity:
Bundleextras= getIntent().getExtras();
if(extras !=null) {
inttypeAct= extras.getInt("activity");
if (typeAct == 1) {
.......
Solution 2:
pass the data in a one bundle
the first activity would for example have three values in the bundle then the second one retrieves the data from the bundle and adds
or 'Append' to the second activity and finally in the third activity you can retrieve the data as a single bundle from the second activity.
Post a Comment for "Passing Data From Two Activities To A Third"