How to simulate HW key events?

215 views
Skip to first unread message

Gerald

unread,
Mar 17, 2009, 10:51:24 PM3/17/09
to android-platform
Hi,
I want to create a virtual key panel just like the status bar but at
the screen bottom.
And I want to put several keys on the panel (Home, Call, Menu, Back,
End Call, etc).
How can I send key events to android system?
Any side effect to the system? (effect KeyGuard?)
Thank you

Gerald

Dianne Hackborn

unread,
Mar 18, 2009, 2:44:22 AM3/18/09
to android-...@googlegroups.com
The approach you probably want to take is to modify PhoneWindowManager to manage your UI and inject the events back into the window manager as desired.  You may implement your UI somewhere else, but at some point PhoneWindowManager needs to know something about it to know how to layout other parts of the screen around it -- see the existing code in there for the status bar as an example.

Note that the current PhoneWindowManager also takes care of standard actions for home and end call in its lower-level event processing, so you will want to make sure to execute those yourself in the same way, since the current API on WindowManagerService for injecting key events bypasses the low-level processing and just sends them directly to the currently focused window.
--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages