model view controller - Android Architecture Design - How to do it right? -


how architecture android app like? should "work/business logic" been done in background service , activity communicates service query/fetch data somewhere (local/distant)?

would implement "service" activity calls real android-service? or pojo-singleton work (perhaps using background threads). or instantiate background threads in activity time-consuming actions (query webservice).

how abstract data access right way? use contentprovider access/abstract data? how/from should queried? activity? service? ..?

i've tried search app architecture design, found how android architecture looks like, not how android app should like.

so what's opinion that? components of android application should communicate each other ensure best extensibility/encapsulation,...?

there's no 1 answer question. oo design isn't android specific. i'd rule - if framework gives high level object (such service in case of android) fits use case, use it. if find making pojo implementations of same things free framework, go framework.

as far separation of concerns, standard oo stuff. don't put in activity classes isn't job of activity. over-stuffing activity methods , properties activity needs aren't job of activity bad - makes intention of activity hard understand.

i separate stuff sub-packages in apps.

  • com.myname.myproject.app - base classes, global application functionality
  • com.myname.myproject.net - network stuff, network related utils
  • com.myname.myproject.data - db helpers, providers, etc
  • com.myname.myproject.model - object model

etc.

as far communication within app...

i have custom application class register in manifest. way, when have controllers , helpers need "single instance", don't have crazy thread safe singleton stuff...i keep 1 global copy of.

roboguice dependency injection framework makes easier accomplish...definitely worth looking into. if interests you, google group roboguice great , filled creators of framework can answer need.

as far in-app communication, use single instance controller , state classes hold state , common tasks, , use broadcastintents communicate activities services


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -