I’m not an Android pro though I’ve developed an app consisting of more than 50 activities which makes the app really large. After 8 weeks of developing, now there are problems which caused the app difficult to maintain and upgrade. Major ones I’m dealing with are
I cannot pass object reference to activities’ constructors. In fact I found the mechanisms of
startActivityForResult
–Intent
–onActivityResult
really limiting and results in dirty code of many constants for actions per activity and a lot ofswitch
case
that is really hard to follow the flow of app.Another problem is that I do not know how to manage the life cycle of the whole app as each activity has its own life cycle.
I had some successful experience with LWUIT and J2ME – polish which ignore J2ME MIDlets (similar to android activity) and implement their own architecture and windowing system with just one MIDlet as entry to the app. I’ve come up with the same idea for android.
To clarify, I’m thinking of an app with just one main Activity
and other activities implemented as objects which extend View
object and these views can be dynamically added to main activity FrameLayout
and stack on each other. Activities’ logic can be implemented in such classes and I've even found a way to implement dialogs in this way.
Business and state objects can be passed to their constructor and it sounds good ignoring its side effect of writing a little more code. This way listeners can also be passed to views’ constructors which makes app UI switch and flow management easier.
But the questions are:
- Is it a good practice?
- Wouldn't it lead me to performance or memory issues?
I'm also aware of
- Android: What is better - multiple activities or switching views manually?
- Don't Overload a Single Activity Screen
- Pattern one activity, multiple views. Advantages and disadvantages
None of these clearly address the issues regarding performance or practice with reasonable evidence or documented reference
Please someone help me with this