Accepted answer

i don't see this "modular" app as anything different from one app, with several packages, each containing discrete functionality, that is adapted to some list of settings or external parameter (either provided by the user or you).

my approach would be to have a "main" package. that package would contain the shared functionality you mention above and serve as the hub for your application. i would then create separate sub-packages for the different "add on" functionality. this allows you to still use the code in your main package with a simple import statement. from your description these additional functions should probably be implemented as a fragment. a fragment is almost a stand alone application with the exception that it is "hosted" by an activity. depending on how these add on functions are used (i cannot tell if they relate to the ui, just background processing etc) you could easily have 3 of 4 different fragments and choose to load only 1 or 3 or 2 of them at runtime.

to control which parts of the code are used i would just set up a simple switching class (it could even be part of the first activity launched, i cant tell from your description above). here i would check for some setting indicating which parts of the app will be "active." this could be easily defined using sharedpreferences to store a specific configuration, e.g. use a and b, prior to delivering the final project. you would then just initialize the fragments you need and display them either (1) individually in a fragment layout element or framelayout; (2) collectively in some other view structure like a viewpager.

i follows your links on the broadcastreceiver and i am still not sure why they are "everything else than recommended." used correctly a broadcastreceiver is very useful. i tend to use a localbroadcastmanager along with a broadcastreceiver to notify other sections of the app when some asynctask, e.g. downloading a lot of data, is complete. these parts of the app can then access a local database or process the information downloaded on their own time. i wouldn't use a broadcastreceiver to modulate parts of the app if that is what you're looking for. i would instead just use a sharedpreference file to set the configuration at runtime.


if you need modules like facebook sdk or something like that better use library project. if you use idea or android studio there is such thing like module. if i need some modeles in one app i prefer just put in different packages like com.appname.model, com.appname.ui and so on. broadcast receiver isn't about modules. as i know there isn't analog of ios target.

Related Query

More Query from same tag