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);
    }
posted @ 2012-06-11 14:31  Qiengo  阅读(274)  评论(0编辑  收藏  举报