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#NEW_TASK_LAUNCH
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
-~----------~----~----~----~------~----~------~--~---