Example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN

List of usage examples for android.view KeyEvent KEYCODE_VOLUME_DOWN

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Prototype

int KEYCODE_VOLUME_DOWN

To view the source code for android.view KeyEvent KEYCODE_VOLUME_DOWN.

Click Source Link

Document

Key code constant: Volume Down key.

Usage

From source file:org.apache.cordova.CordovaWebViewImpl.java

@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_BACK:
        // TODO: Why are search and menu buttons handled separately?
        if (override) {
            boundKeyCodes.add(keyCode);//  w w w  .  j  av  a 2 s .  com
        } else {
            boundKeyCodes.remove(keyCode);
        }
        return;
    default:
        throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
    }
}

From source file:aarddict.android.ArticleViewActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        goBack();//from  www .  j a va2  s  . c  o m
        break;
    case NOOK_KEY_PREV_LEFT:
    case NOOK_KEY_PREV_RIGHT:
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (!articleView.pageUp(false)) {
            goBack();
        }
        break;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case NOOK_KEY_NEXT_LEFT:
    case NOOK_KEY_NEXT_RIGHT:
        if (!articleView.pageDown(false)) {
            nextArticle();
        }
        ;
        break;
    default:
        return super.onKeyDown(keyCode, event);
    }
    return true;
}

From source file:org.apache.cordova.engine.crosswalk.XWalkCordovaWebView.java

@Override
public void setButtonPlumbedToJs(int keyCode, boolean value) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_BACK:
        // TODO: Why are search and menu buttons handled separately?
        boundKeyCodes.add(keyCode);/* w  ww.  j  av  a2 s  .c  o m*/
        return;
    default:
        throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
    }
}

From source file:org.apache.cordova.X5CordovaWebViewImpl.java

@Override
public void setButtonPlumbedToJs(int keyCode, boolean override) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_DOWN:
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_BACK:
    case KeyEvent.KEYCODE_MENU:
        // TODO: Why are search and menu buttons handled separately?
        if (override) {
            boundKeyCodes.add(keyCode);/*w  w w  .j a  v a  2 s  . c  om*/
        } else {
            boundKeyCodes.remove(keyCode);
        }
        return;
    default:
        throw new IllegalArgumentException("Unsupported keycode: " + keyCode);
    }
}

From source file:im.vector.activity.CallViewActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // assume that the user cancels the call if it is ringing
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (!canCallBeResumed()) {
            if (null != mCall) {
                mCall.hangup("");
            }//from   ww  w  . j a v  a2  s.  co  m
        } else {
            saveCallView();
        }
    } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) || (keyCode == KeyEvent.KEYCODE_VOLUME_UP)) {
        // this is a trick to reduce the ring volume :
        // when the call is ringing, the AudioManager.Mode switch to MODE_IN_COMMUNICATION
        // so the volume is the next call one whereas the user expects to reduce the ring volume.
        if ((null != mCall) && mCall.getCallState().equals(IMXCall.CALL_STATE_RINGING)) {
            AudioManager audioManager = (AudioManager) CallViewActivity.this
                    .getSystemService(Context.AUDIO_SERVICE);
            // IMXChrome call issue
            if (audioManager.getMode() == AudioManager.MODE_IN_COMMUNICATION) {
                int musicVol = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL)
                        * audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
                        / audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
                audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicVol, 0);
            }
        }
    }

    return super.onKeyDown(keyCode, event);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        event.startTracking();/*w w w  .j  a va  2  s  .c  o  m*/
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        event.startTracking();
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK) {
        Intent record = new Intent(getActivity(), VoiceQuickRecordActivity.class);
        record.putExtra("feed_uri", mFeedUri);
        startActivity(record);
        return true;
    }
    return false;
}

From source file:aarddict.android.ArticleViewActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    // eat key ups corresponding to key downs so that volume keys don't beep
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        break;/*  w w  w.j a v  a2 s .c  om*/
    default:
        return super.onKeyDown(keyCode, event);
    }
    return true;
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * {@inheritDoc}/*from   w  w  w.ja  va  2s .  com*/
 */
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    /**
     * The call to:
     * setVolumeControlStream(AudioManager.STREAM_VOICE_CALL)
     * doesn't work when notification was being played during this Activity
     * creation, so the buttons must be captured and the voice call level
     * will be manipulated programmatically.
     */
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_UP) {
            volControl.onKeyVolUp();
        }
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            volControl.onKeyVolDown();
        }
        return true;
    default:
        return super.dispatchKeyEvent(event);
    }
}

From source file:com.marvin.rocklock.RockLockActivity.java

/**
 * Pick up back button and volume up and down
 *///  w w w . ja  v a  2  s.  co  m
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        mPlayer.togglePlayPause();
        return true;
    case KeyEvent.KEYCODE_MEDIA_NEXT:
        mPlayer.nextTrack(false);
        return true;
    case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
        mPlayer.prevTrack(false);
        return true;
    case KeyEvent.KEYCODE_VOLUME_UP:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                AudioManager.FLAG_PLAY_SOUND);
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                AudioManager.FLAG_PLAY_SOUND);
        return true;
    case KeyEvent.KEYCODE_BACK:
        onBackPressed();
        return true;
    default:
        return super.onKeyDown(keyCode, event);
    }
}

From source file:com.CrestronXPanelApp.CrestronXPanelApp.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        if (event.getRepeatCount() == 0 && specialList.containsKey("sideup")) {
            sendDigitalListMessage(specialList.get("sideup"), 1);
        }//from  w w  w  .j av a2  s .c o  m
        return true;
    }
    if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (event.getRepeatCount() == 0 && specialList.containsKey("sidedown")) {
            sendDigitalListMessage(specialList.get("sidedown"), 1);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}