Modern day smart-phones have already begun to migrate from the traditional "a-button-for-every-need" approach to the "huge-display-cum-touchscreen" form-factors. Android phones are no exception. But, traditional buttons are still reqd. for a few oft used functions (power,back,home,menu etc.) And smart-phones continue to have them alongwith the primary touch-based-UI.
Android-OS provides a very easy method to simulate key/button press/release events via software. You might ask why do we need a software to generate the events when a hardware button is already present on the device. Here's why:
- During development/testing of the button-drivers itself.
- To implement automated rigorous tests. ( MonkeyTest? )
- To implement/interface additional custom software keyboards.
- Just because we can!
The reason why i am doing it today is REASON NUMBER 4.
Now, the basic goal of this exercise is extremely simple:
Q. How to generate a hardware-button-press event
WITHOUT actually pressing any key on the device?