I’m starting Android app development and just after my very first app more complex than Hello World I found out that you cannot hold any state in Activity because Android will recreate them in some cases… ouch, failure.
I’m guessing that strict model separation from view is a common practice, even for simple apps. Are there any settled patters I should follow? Some variant of Model-View-Controller?
I’m starting Android app development and just after my very first app more complex
Share
You should definitely read the Application Fundamentals Dev Guide
In my experience, my design patterns in Android have been driven by the use of
Intents,Activities,Services,Broadcast receiversand so forth.I wouldn’t say that “strict model separation from view is a common practice”. You can keep data inside an Activity, but you will be forced to preserve it. Luckily this is made trivial by methods like
onSaveInstanceStateandonRestoreInstanceStatewhere persistent data members can be saved to aBundleand then retrieved from the sameBundle.