Not to mention that, unless your app is dirt-simple, doing everything in one
Activity would be a maintenance nightmare. Don't do this to yourself.

Think of each Activity as something the user *does* and each layout as what
the user *sees* when doing that. So each Activity could have multiple
layouts depending on how you want to present the screen to them while they
do that action, but theoretically you would have a different Activity for
each major function / action you can do with your app.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking


On Tue, Dec 8, 2009 at 12:13 AM, Mark Murphy <mmur...@commonsware.com>wrote:

> > Again I am confused a little. If I can show a different layout calling
> > setContentLayout, please anybody can give me an example of a
> > compelling situation where my app would need more than one activity ?
>
> Here are a starting set of arguments, and I am sure there are more to be
> made:
>
> 1. Doing everything inside of one activity may cause garbage collection
> issues. Activities are specifically designed to be "disposable".
>
> 2. Doing everything inside of one activity means either the user cannot
> use the BACK button to navigate, or you have to do that yourself. For
> example, imagine a Web browser where the BACK button closed up the browser
> window, or where each Web site had to maintain its own "browser history"
> for each user.
>
> 3. Handling screen rotation via onSaveInstanceState() or the like becomes
> proportionally more difficult as you add "screens" to an existing
> activity, rather than have them as independent activities.
>
> 4. Some applications will want multiple activities as multiple entry
> points into the application itself (e.g., main activity versus an app
> widget configuration activity).
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> Android App Developer Books: http://commonsware.com/books.html
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to