android - Activity and fragment responsibilities in network communication (robospice) -


i creating apps using robospice library. great choice handle internet connections, because core of library based on android service, our connections not tied activity life-cycle.
creating our requests , executing them spice manager in turn instantiated in each activity (base activity inheritance) , don't right way place creating of manage object here, if there better way this, please let me know.

public class baseactivity extends appcompatactivity implements activitycontroller, spicemanagerprovider {     private spicemanager mspicemanager = new spicemanager(myrobospiceservice.class); 

i have been creating request (robospice requests) need them in fragments , activities. thought little bit this. maybe better separate request handling in activities. , listening button clicks or whatever fragments in activity callback methods or other inter component communication. , in activity make request, handle it. in case if need data in fragment have send activity fragment. seems lot of redundant communications.

all in wan't advice more experienced developers separation of responsibilities, should handle request in 1 component (like activity) or can make , handle requests anywhere need this.
in advance.

using single spicemanager per activity , sharing between fragments have done in past. have to, unfortunately, check if activity still resumed in case every response listener. specific, need sure not update stopped or destroyed ui.

see related faq question more details.

the second paragraph there mentions the other approach of having spicemanager per fragment, should viable option well. noticed overhead while creating spicemanagers (this hurts when there many fragments) , therefore abandoned our use.


Comments