如何使用nativescript监听android中的音量增大/减小键?

时间:2017-08-29 15:55:18

标签: android nativescript

我只想知道如何在本机脚本中访问音量增大和减小键。

1 个答案:

答案 0 :(得分:1)

我不知道您要尝试的电源按钮,但要处理按键事件,您可以尝试覆盖KeyCode

简而言之,您处理事件并处理Action@Override public boolean dispatchKeyEvent(KeyEvent event) { // Which direction did the key move (up/down) int action = event.getAction(); // What keywas pressed int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: // Check your event code (KeyEvent.ACTION_DOWN, KeyEvent.ACTION_UP etc) return true; case KeyEvent.KEYCODE_VOLUME_DOWN: // Check your event code (KeyEvent.ACTION_DOWN, KeyEvent.ACTION_UP etc) return true; default: // Let the system do what it wanted to do return super.dispatchKeyEvent(event); } } - 类似这样的事情

KeyEvent

以下是despatchKeyEventfull list选项。希望这会让你前进。有关$ openssl sha256 -sign privatekey.pem myfile.txt > right.result here

的简短说明