On Mon, Aug 16, 2010 at 10:38 PM, David <[email protected]> wrote: > Are there design guidelines to help decide if an application with multiple > views should be designed with multiple activities or just one activity and > control the back button itself. >
Not that I'm aware of, but the pattern seems to be one Activity per "action" your app does. This is not necessarily the same as one Activity per view, as one Activity could do one thing but have multiple views to show the data differently as Frank suggests. > I've tried both. My most complex applications using one activity > per screen. However, now that I'm successfully written an app with just one > activity and handling the back button myself, I don't see any compelling > reason to use multiple activities. The one activity application is much > simpler and more straightforward. > How many screens are you managing in your one-Activity app? I have to believe at some point managing the state of all your different views in one activity will grow to be unmanageable. > What advantages of multiple activities am I missing? > On top of the excellent points by Mark, there's the whole notion of separating responsibilities. I think each Activity as encapsulating some task your app can perform. If you can clearly define and separate these tasks, your code and app will be far more maintainable, reusable, and enhanceable. Throw everything into a monolithic Activity and you're looking at a maintenance nightmare for all but the simplest apps. ------------------------------------------------------------------------------------------------- TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

