There are some parts of the framework that are not yet entirely clear to me. I am well acquainted with the flow of the input event (Kernel -> Eventhub -> InputReader -> InputDispatcher -> ...).
Situation
(Requirements: the key entry handle without changing the Android Framework.) I want to handle key events coming from the device (keyboard / gamepad / controller / ...), but there are some requirements. Firstly, I do not want to change the Android platform. This means that I do not want to extend WindowManagerPolicy and its functions, such as interceptKeyBeforeDispatching , where the home key is processed. This will cause the key event to be sent to the application layer. The downside is that I have one more difficult requirement. Example: When I play Angry Birds and I press the GoToAlpha button on a connected input device, you need to run an Alpha application. Angry Birds has no idea which GoToAlpha button will not process / recognize it, and, for example, there will be no translation to launch my Alpha application.
Question
Is there a way to handle my (custom) key event after sending it, knowing that the application in the foreground cannot process the key?
My (unsuccessful) decisions
Create a service that will handle key events. This is not possible because an application like Angry Birds will not be tied to my service and the key event will not be caught on my service. If I am mistaken, provide additional information :).
Create an external library where I allow my applications to inherit their own ActivityBase. All key events and default behavior can be handled here. Downside, existing applications will not support my custom key events because they do not use the library.
Expanding the scope will be in my eyes the purest solution, but this will lead to non-compliance with my requirements.
Any help or helpful information would be appreciated.
Extra
If the first question can be resolved anyway .. I want to configure my Intent behind the GoToAlpha button. This means that by default the Alpha application will be launched, but after the user has configured it, the beta application will be launched from this point on .. Any thoughts?
thanks
android key-events
Droidbender
source share