Combination of power button and volume up button in android

后端 未结 1 1946
清歌不尽
清歌不尽 2021-01-23 08:15

Like the combination of Power button and Volume down button - takes a screenshot of the phone... similarly I am trying to access volume up and power button long pressed keys in

相关标签:
1条回答
  • 2021-01-23 08:34

    I don't understand programming under android, but I see it uses Java classes, so try this

    public class BitKeys implements KeyListener {
    
        private BitSet keyBits = new BitSet(256);
    
        @Override
        public void keyPressed(final KeyEvent event) {
            int keyCode = event.getKeyCode();
            keyBits.set(keyCode);
        }
    
        @Override
        public void keyReleased(final KeyEvent event) {
            int keyCode = event.getKeyCode();
            keyBits.clear(keyCode);
        }
    
        @Override
        public void keyTyped(final KeyEvent event) {
            // don't care
        }
    
        public boolean isKeyPressed(final int keyCode) {
            return keyBits.get(keyCode);
        }
    
    }
    

    I found this here : handle multiple key presses ignoring repeated key

    0 讨论(0)
提交回复
热议问题