2

Currently, can press volume button and menu to activate screen recording on Lenovo Mirage Solo daydream device. Is there a way to trigger this same function programmatically?

I've looked through the documentation and cannot find anything relevant.

jadware
  • 165
  • 1
  • 9

1 Answers1

0
KeyEvent volDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_DOWN);
Activity.dispatchKeyEvent(volDown);
KeyEvent menuDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent. KEYCODE_MENU);
Activity.dispatchKeyEvent(menuDown);

KeyEvent volUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_DOWN);
Activity.dispatchKeyEvent(volUp);
KeyEvent menuUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent. KEYCODE_MENU);
Activity.dispatchKeyEvent(menuUp);

I haven't tested this because I don't have this phone, but here is my best guess. The first four lines press the volume and menu keys down (ACTION_DOWN), and the second four lines release them (ACTION_UP). Hopefully it works for you :) I'm assuming this works with menu and volume-down, but if it's volume-up then just swap KEYCODE_VOLUME_DOWN for KEYCODE_VOLUME_UP

MSpeed
  • 8,153
  • 7
  • 49
  • 61