MC330K, Android 8.1 - how to programmatically listen to P1 and P2 HW keys without remapping them?

D Dmitrii Semikin 3 years 7 months ago
51 1 0

Hello,
I work with MC330K, Android 8.1. Application is written using standard Android Java SDK.
My goal is to override the default behavior of buttons P1 and P2. Currently P1 acts as "back" button and P2 as "APP_SWITCH".
The constraint is also not to use Key Programmer (from Android Settings), so that user does not need to change global settings and can have different settings across applications.
Currently I tried to override "dispatchKeyEvent()" and "onKeyUp()"/"onKeyDown()" of the current Activity and also use onKeyListener on the currently active EditText, but the Problem is that these callbacks do not even get triggered, when P1 or P2 key is pressed.
Could someone, please, explain, how to react (override) the events from P1 and P2 keys?
Thank you.
Edit: In fact with default mapping P1 key (mappt to "BACK" as default), it eventually ends up in the EditText keyListener. On a first press it closes to on-screen keyboard (not caught by any listeners mentioned above) and on a second press it is being caught by EditText's keyListener as a "BACK-key" event. I.e. the behavior is exactly the same as for standard "triangle" (aka "back") android on-screen key. But this is not the desired behavior. So I would like to intercept this event from the key before it was converted into "BACK" event.

Please Register or Login to post a reply

1 Replies

D Darryn Campbell

Hi, I don't think this is possible, the keys are handled by Android before they are sent to the text field / app for processing and capturing by onKeyDown / onKeyUp.
Typically I would suggest remapping these keys but you say that is not an option programmatically, would you be open to remapping them through EMM or StageNow as part of your provisioning process?

CONTACT
Can’t find what you’re looking for?