List of usage examples for android.view KeyEvent KEYCODE_VOLUME_DOWN
int KEYCODE_VOLUME_DOWN
To view the source code for android.view KeyEvent KEYCODE_VOLUME_DOWN.
Click Source Link
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent keyEvent) { // Do this in dispatch to intercept a few of the system keys. LogUtils.v(LOGTAG, "dispatchKeyEvent: %s", keyEvent); switch (keyEvent.getKeyCode()) { // Volume keys and camera keys dismiss the alarm. case KeyEvent.KEYCODE_POWER: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_FOCUS: if (!mAlarmHandled && keyEvent.getAction() == KeyEvent.ACTION_UP) { switch (mVolumeBehavior) { case SettingsActivity.VOLUME_BEHAVIOR_SNOOZE: snooze();//w w w . j a v a 2s. c o m break; case SettingsActivity.VOLUME_BEHAVIOR_DISMISS: dismiss(); break; default: break; } } return true; default: return super.dispatchKeyEvent(keyEvent); } }
From source file:org.protocoderrunner.base.BaseActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { MLog.d(TAG, "" + keyCode); if (AppSettings.OVERRIDE_VOLUME_BUTTONS && (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { return true; }//from www .ja v a2s . c o m if (keyCode == KeyEvent.KEYCODE_BACK && AppSettings.CLOSE_WITH_BACK) { finish(); return true; } return super.onKeyDown(keyCode, event); }
From source file:org.easyaccess.phonedialer.CallingScreen.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (KeyEvent.KEYCODE_VOLUME_UP == event.getKeyCode()) { if (Utils.ringing == 1) { // announce the caller name/number announceCaller(this.callerDetails); return true; } else if (Utils.ringing == 0 && Utils.off_hook == 1) { // activate loudspeaker Utils.audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); if (Utils.audioManager.isSpeakerphoneOn() == false) { Utils.audioManager.setSpeakerphoneOn(true); } else { // deactivate loudspeaker Utils.audioManager.setSpeakerphoneOn(false); }//from ww w . j a va 2 s .c om return true; } } else if (KeyEvent.KEYCODE_VOLUME_DOWN == event.getKeyCode()) { if (Utils.ringing == 1) { // mute the ringtone muteRingtone(); return true; } else if (Utils.ringing == 0 && Utils.off_hook == 1) { if (Utils.audioManager.isMicrophoneMute() == true) { Utils.audioManager.setMicrophoneMute(false); } else { Utils.audioManager.setMicrophoneMute(true); } return true; } } return super.onKeyUp(keyCode, event); }
From source file:de.qspool.clementineremote.ui.MainActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent keyEvent) { if (mSharedPref.getBoolean(App.SP_KEY_USE_VOLUMEKEYS, true)) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return true; }/*from ww w .jav a 2 s .com*/ } return super.onKeyUp(keyCode, keyEvent); }
From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java
@Override public boolean dispatchKeyEvent(@NonNull KeyEvent keyEvent) { // Do this in dispatch to intercept a few of the system keys. LOGGER.v("dispatchKeyEvent: %s", keyEvent); final int keyCode = keyEvent.getKeyCode(); switch (keyCode) { // Volume keys and camera keys dismiss the alarm. case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_FOCUS: if (!mAlarmHandled) { switch (mVolumeBehavior) { case SNOOZE: if (keyEvent.getAction() == KeyEvent.ACTION_UP) { snooze();//from w w w . ja v a 2s. c om } return true; case DISMISS: if (keyEvent.getAction() == KeyEvent.ACTION_UP) { dismiss(); } return true; } } } return super.dispatchKeyEvent(keyEvent); }
From source file:com.qiusheng.cast.CastActivity.java
/** * Processes volume up and volume down actions upon receiving them as key * events.//from w w w .ja v a2 s . com */ @Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mMessageStream != null) { currentVolume = mMessageStream.getVolume(); logVIfEnabled(TAG, "Volume up from " + currentVolume); if (currentVolume < 1.0) { logVIfEnabled(TAG, "New volume: " + (currentVolume + VOLUME_INCREMENT)); onSetVolume(currentVolume + VOLUME_INCREMENT); } } else { Log.e(TAG, "dispatchKeyEvent - volume up - mMessageStream==null"); } } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { double currentVolume; if (mMessageStream != null) { currentVolume = mMessageStream.getVolume(); logVIfEnabled(TAG, "Volume down from: " + currentVolume); if (currentVolume > 0.0) { logVIfEnabled(TAG, "New volume: " + (currentVolume - VOLUME_INCREMENT)); onSetVolume(currentVolume - VOLUME_INCREMENT); } } else { Log.e(TAG, "dispatchKeyEvent - volume down - mMessageStream==null"); } } return true; default: return super.dispatchKeyEvent(event); } }
From source file:org.xbmc.android.remote.presentation.activity.MovieLibraryActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { IEventClientManager client = ManagerFactory.getEventClientManager(mMovieController); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: client.sendButton("R1", ButtonCodes.REMOTE_VOLUME_PLUS, false, true, true, (short) 0, (byte) 0); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: client.sendButton("R1", ButtonCodes.REMOTE_VOLUME_MINUS, false, true, true, (short) 0, (byte) 0); return true; }//from ww w . j a va2 s .c om client.setController(null); return super.onKeyDown(keyCode, event); }
From source file:org.chromium.chrome.browser.media.remote.ExpandedControllerActivity.java
/** * Modify remote volume by handling volume keys. * * @param controller The remote controller through which the volume will be modified. * @param event The key event. Its keycode needs to be either {@code KEYCODE_VOLUME_DOWN} or * {@code KEYCODE_VOLUME_UP} otherwise this method will return false. * @return True if the event is handled. *//*from w w w.java 2s.co m*/ private boolean handleVolumeKeyEvent(MediaRouteController controller, KeyEvent event) { if (!controller.isBeingCast()) return false; int action = event.getAction(); int keyCode = event.getKeyCode(); // Intercept the volume keys to affect only remote volume. switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) controller.setRemoteVolume(-1); return true; case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) controller.setRemoteVolume(1); return true; default: return false; } }
From source file:org.libreoffice.impressremote.activity.SlideShowActivity.java
@Override public boolean onKeyDown(int aKeyCode, KeyEvent aKeyEvent) { if (!areVolumeKeysActionsRequired()) { return super.onKeyDown(aKeyCode, aKeyEvent); }/*from w w w . ja v a2 s. c om*/ switch (aKeyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (!isLastSlideDisplayed()) { mCommunicationService.getCommandsTransmitter().performNextTransition(); } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: mCommunicationService.getCommandsTransmitter().performPreviousTransition(); return true; default: return super.onKeyDown(aKeyCode, aKeyEvent); } }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED);//from ww w. ja v a2s.c o m finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); return true; } return super.onKeyDown(keyCode, event); }