Christian Neverdal Jonassen
Sep 27, 2017
4:08 pm

Change the behavior of the XCover key (something "entirely custom" that is not just lauching another app).

What is the preferred way of listening to the XCover button and make it do something "custom"?

 

I tried this:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
   switch (keyCode) {
      case 1015:
         Toast("XCover key long pressed!");
         break;
      default:
         Toast(String.format("onKeyLongPress: %s %s", keyCode, " (" + KeyEvent.keyCodeToString(keyCode) + ")"));
   }
   return super.onKeyDown(keyCode, event);
}
however, for the XCover key this did not work.
I tried adding

 
SettingsManager kcsm = SettingsManager.getInstance();
logAndToast(kcsm.setXCoverKeyApp(this.getPackageName(), this.getLocalClassName(), CustomDeviceManager.ACTIVE_KEY_SHORT_PRESS));
logAndToast(kcsm.setXCoverKeyApp(this.getPackageName(), this.getLocalClassName(), CustomDeviceManager.ACTIVE_KEY_LONG_PRESS));

 
but that did not help either.

 
What am I doing wrong, and what should I do?
Samuel Goldwax
Sep 27, 2017
4:33 pm

Hi Christian,

Unfortuntely the Knox Customization SDK doesn't support this use case as it is already supported by the base Android platform.

I cannot suggest a best practice for implementing this but perhaps the following page will help you:

https://stackoverflow.com/questions/36551794/how-to-detect-a-long-press-...

 

Thanks,

Sam