I checked my code, and I was giving the Application to the View
Constructor, as the context, which I believe is correct, although we
can also pass the activity (this)
My code was:
setContentView( new GameMenuView( getApplication() ) );
> Well, you have a range of choices:
>
> - Using NEW_TASK_LAUNCH like this is fundamentally broken (unless that
> is the semantics you really want)/
That's why I was saying that I didn't get how this View => Activity
communication was supposed to work, since this flag (Hack) solution is
NOT a reasonable/natural solution in this case.
> - Performing a cast is a quick and dirty style that you can use when
> you know exactly how your View class will be used.
Exactly, Quick & Dirty => Hack :)
> - You can give an explicitly Activity object to the view, which allows
> the view to work in all situations though it may be awkward to hook
> things up.
Yes, I have seen this also in some example code, but I never felt it
as a natural solution, it seems like a hack too.
> - Or you can have a formal callback interface from the view, like the
> various ones used in the platform frameworks, which is the cleanest
> approach.
Can you give me a specific and relevant example reference (URL)?
Thanks
> > But this probably hints that something must be changed in the
> > interface between an Activity and a View.
> > Since, the need to force casts to input of an API, is usually sign of
> > a not so good solution.
>
> No, this is intentional. A view may very well not be running inside
> of an activity. For example, it could be put in a dialog, in which
> case there is no activity to finish.
>
> > Is this Activity - View communication model, by any chance already
> > being review for future versions?
> > If Yes, any info on it, that could be advanced before hand ?
>
> We don't expect any major changes to it.
I would then suggest that this API "subtlety" should be documented in
the View Documentation, so that everyone knows that this is expected/
designed behaviour, and how we should handle it (like a best practices
example), because I'm sure that I'm not the only one to find this
solution "un-natural", at least for the most common case.
It would probably clarify a lot of the initial doubts related with how
to communicate between views and activities, that are sure to pop in.
once again, thank you for the insights.
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---