java - Passing data from two activities to a third -


i have total 3 activites. pass data first activity this:

 intent = new intent(getapplicationcontext(), history.class);         i.putextra("day", mday);         i.putextra("month", mmonth+1);         i.putextra("year", myear);         startactivity(i); 

get data:

bundle extras = getintent().getextras();      if(extras !=null) { ....... 

now pass data second activity:

intent = new intent(getapplicationcontext(), history.class);                 i.putextra("hday", mday);                 i.putextra("hmonth", mmonth);                 i.putextra("hyear", myear);                 startactivity(i); 

and data second activity:

bundle extras2 = getintent().getextras();      if(extras2 !=null) { 

so, have extras data first activity, , extras2 data second activity. when pass data activity both extras not null! have done wrong?

the problem third activity has no way of knowing activity sent bundle. need add field identifies type of bundle can process accordingly. instance, in activity 1:

intent = new intent(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:

bundle extras = getintent().getextras();      if(extras !=null) {         int typeact = extras.getint("activity");        if (typeact == 1) { ....... 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -