Android Volume Button Listener

Simple,just need to override the onKeyDown method of the current activity:

 @Override

    public boolean onKeyDown(int keyCode, KeyEvent event) {

        switch (keyCode) {

        case KeyEvent.KEYCODE_VOLUME_DOWN:

            SwitchPage(true);

            return true;

        case KeyEvent.KEYCODE_VOLUME_UP:

            SwitchPage(false);

            return true;

        }

        return super.onKeyDown(keyCode, event);

    }

你可能感兴趣的:(listener)