Android: pass data from activity with 3 fragments to previous activity -


i'm building android app using android studio. let's have activity1 , activity2. activity2 has 3 fragments (3 tabs). managed pass data activity1 activity2 , activity2 it's fragments using fragment adapter.

1) want opposite: gather data 3 fragments , pass activity sitting in (activity2), , pass data activity2 activity1.

i have implemented interface passes data 1 fragment activity2, how (and when) can pass data 3 fragments activity2? method wrote sends object fragment activity2. method in activity2 gets 1 object... or perhaps there's way can send data fragments activity2 fragment adapter? (this can best think...)

2) best way pass data activity2 activity1 overriding "onbackpressed" , using startactivityforresult , setresult? (i don't have button besides actionbar "back button").

thanks!

1) can create interface 3 methods like: setresult1(), setresult2() , setresult3() , make activity implement interface can collect results of 3 fragments available. fragments should call own method in interface result changes, , after restoration (in case activity re-created, when change orientation).

2) activity2 send result activity1, best way start activity2 activity1 startactivityforresult(). each time new result collected activity2 should call setresult(int resultcode, intent data). can call multiple times replace previous result. if set result don't need override onbackpressed().


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -