Thursday, January 24, 2013

Re: [android-developers] Android MVC

Using the Application class indicates that you're doing something wrong.

Android apps are meant to die. You don't have a "global app state:"
instead your state should be stored in a ContentProvider and
individual Activity state.

In short, you really shouldn't be doing this. There are ways to
notify other pieces of the app of content changes: look into using a
`ContentObserver`

Kris

On Tue, Jan 22, 2013 at 5:53 PM, dashman <erjdriver@gmail.com> wrote:
> I'm starting to write an app that'll have several separate screens - maybe
> displayed
> on the page at the same time (using Fragments) - maybe not.
>
> They all share a global app state. That is, if one screen modifies the
> state, I want it
> notified autmatically to the other screens. In the olden days it used to be
> called MVC design. i want my app logic to be centralized with all the views
> sharing
> a single instance and be notified when someting changes.
>
>
> To implement this, Application() sub-class seems to fit the bill.
>
> 1. If one screen changes a global variable - how to do notify the other
> pages of the
> change.
>
> 2.In android my understanding is that there can be one 1 activity active on
> the screen.
> There's just 1 FragmentActivity active - displaying multple Fragments right?
>
> In my case I would all the Fragments to share the same getApplication()
> object - but
> be able to notify all the fragments on state change.
>
>
> Any suggestions how how to optimally design the app - appreciated.
>
>
> --
> 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+unsubscribe@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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment