Sunday, August 7, 2011

[android-developers] Re: At what point does android know the exact key that was pressed?

On Aug 6, 12:07 pm, Anil <anil.r...@gmail.com> wrote:
> I built the android source and running it in the Eclipse debugger, am
> trying to understand where is the point in the calling sequence when
> it has all the information about the event.
> So I run the calculator and press key '1'. There is a breakpoint at
> EventListener.onClick()
> In the call stack I see the event being dispatched; ViewRoot calling
> PhoneWindow calling Panel, Layout, Button etc. until the handler is
> reached.
> questions:
> 1) At what earliest point in the call hierarchy can I insert a println
> saying, "Key was pressed, value is 1"?

In one of your view's registered OnKeyListeners, unless you want to
create a custom mod of Android to do something different. Or if no
view intercepts the key, in the containing activity's onKeyDown()

> 2) At what point does it know whether it was a soft key or a physical
> key?

It's a flag in the KeyEvent that was passed to one of the above
mechanisms. There is no additional waiting for that information.

If you're trying to intercept keys before the normal mechanisms,
that's not allowed. Otherwise you might have third party apps logging
your keypresses and possibly stealing your passwords.

Doug

--
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