Possibly an important piece of information that I haven't mentioned
before.
I'm NOT using the available Android widjets, like buttons and similar,
to avoid GUI problems between SDKs, specially since the application is
a game, and is NOT common to use the phone OS GUI inside a game.
Games usualy provide a GUI interface of their own, in order to be able
to control all aspects of the Graphical Interface.
So, I'm drawing all my View contents, using Drawables, and processing
the onKeyDown and onMotionEvent/onTouchEvent inputs myself.
And obviously I'm not setting these view components through
androidManifest.xml. I only declare my Activities there and that's it.
On 8 abr, 06:54, Rui Martins <[EMAIL PROTECTED]> wrote:
> Another Example:
> How do we call our activity finish method, from our activity view
> class ?
>
> Inside an Activity context, we can just call finish();
>
> Inside a view, apparently we can't get a reference to the Activity
> that contains us (the view), and even if there is a way to get the
> reference, we can't probably call it directly, due to UI threading
> issues.
>
> So, do we send a message ? How ?
>
> How do we get the reference to the Handler defined inside our
> Activity, to be able to call myHandler.sendMessage(...) ?
>
> I think the UI handling code is complex and cumbersome to work with.
>
> I agree that probably should use messaging, since this helps to
> decouple the several application parts, but the current API, is not
> very helpful, in making the common message usage simple.
>
> Any help on this would be great too.
>
> Thanks
>
> On 8 abr, 06:22, Rui Martins <[EMAIL PROTECTED]> wrote:
>
> > I have been programming for android since January, and I must say,
> > that I still don't get how the communication between Views and
> > Activities is accomplished successfully.
>
> > The whole design on this communication is "fuzzy" at least for me.
>
> > NOTE: using M3 currenlty.
>
> > Examples:
> > Activities can have menus, creating when onCreateOptionsMenu( Menu
> > menu ) is called
> > Later we can get the menu selection by implementing
> > onOptionsItemSelected( Menu.Item item ).
>
> > So, inside and Activity, we have access to user actions/input in the
> > form of a menu, and hence we can react to it, for example, by
> > launching another activity (typical usage).
>
> > This works, because we are in the context of the activity.
>
> > NOTE: This is what I'm using now, so that I could keep on developing
> > until I find a solution to my problem (next).
>
> > Now if, you look at the View object, it's the only one to have user
> > input handlers, like:
> > onMotionEvent( MotionEvent event ) ( or onTouchEvent for M5), and
> > onKeyDown( int keyCode, KeyEvent event ) !
> > An Activity doesn't have those !
>
> > So, how can we handle user input, and react accordingly ?
>
> > If we call intent.startActivity() from within a View , we get an
> > "Application Error", with the following description:
>
> > "An error has occurred in process XXX
> > calling startActivity() from outside of an Activity context requires
> > the NEW_TASK_LAUNCH flag.
> > is this really what you want ?"
>
> > The explanation, stating that a flag is required is fine !
> > But how am I to know the answer to the question ? ("is this really
> > what you want ?")
>
> >http://code.google.com/android/reference/android/content/Intent.html#...
>
> > If I force the Flag, I will enter into further configuration problems
> > or limitations, due to how we MUST setup the Activity launchMode
> > (http://code.google.com/android/reference/android/
> > R.attr.html#launchMode)
>
> > Which means, that I will have several simultaneous tasks for every
> > menu option, which is not what was wanted. I can possibly set my
> > lauchMode to "singleTask", but "is this really what I want ?"
>
> > I'm just trying to do a simple common thing, react to user input by
> > launching a specific "sub" activity of the application, like in a menu
> > kind of way.
>
> > I know that there is the concept of subActivity in M5, that probably
> > helps (not sure though), but this should be easy to do, even in M3 and
> > apparently it's not !
>
> > Either I'm missing something, or I haven't still got it, how this is
> > supposed to work.
> > And having Documentation only for M5 stuff, doesn't help much either.
>
> > Enlightnment on this subject and the View/Activity communcation/user
> > input duality would be real nice.
>
> > I needed this to work to finish my Contest entry! :(
>
> > Or else I have to keep using the general Menu, instead of my game
> > Menu, which doesn't quite cut it for a game application.
>
> > NOTE:
> > I'm trying NOT to break the rest of my app, by Porting the remaining
> > stuff to M5.
> > I have an early version that I had ported to M5, but I went back due
> > to some stuff not working on M5, so not really an option.
> > I also don't expect a new SDK Release now so close to the contest
> > deadline, which could fix a lot of things, but could also bring a
> > whole lot of new bugs too.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---