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.sveder.cardboardpassthrough.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) && activado == false) { activado = true;/* w w w . java 2 s.c o m*/ status = 1; mOverlayView.show3DToast("Activando reconocimiento de voz"); handler.post(voiceRecognizer); } else if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) && activado == true) { status = 0; activado = false; mOverlayView.show3DToast("Desactivando reconocimiento de voz"); } else { mOverlayView.show3DToast("Primero tiene que activar el reconocimiento"); } return true; }
From source file:de.qspool.clementineremote.ui.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { int currentVolume = App.mClementine.getVolume(); // Control the volume of clementine if enabled in the options if (mSharedPref.getBoolean(App.SP_KEY_USE_VOLUMEKEYS, true)) { int volumeInc = Integer .parseInt(mSharedPref.getString(App.SP_VOLUME_INC, Clementine.DefaultVolumeInc)); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: Message msgDown = Message.obtain(); msgDown.obj = ClementineMessageFactory .buildVolumeMessage(App.mClementine.getVolume() - volumeInc); App.mClementineConnection.mHandler.sendMessage(msgDown); if (currentVolume >= volumeInc) { currentVolume -= volumeInc; } else { currentVolume = 0;/* w w w . j a va 2s. c o m*/ } makeToast(getString(R.string.playler_volume) + " " + currentVolume + "%", Toast.LENGTH_SHORT); return true; case KeyEvent.KEYCODE_VOLUME_UP: Message msgUp = Message.obtain(); msgUp.obj = ClementineMessageFactory .buildVolumeMessage(App.mClementine.getVolume() + volumeInc); App.mClementineConnection.mHandler.sendMessage(msgUp); if ((currentVolume + volumeInc) >= 100) { currentVolume = 100; } else { currentVolume += volumeInc; } makeToast(getString(R.string.playler_volume) + " " + currentVolume + "%", Toast.LENGTH_SHORT); return true; default: break; } } } return super.onKeyDown(keyCode, event); }
From source file:com.darly.im.ui.CCPActivityBase.java
/** * * @param keyCode//w ww .j a v a 2 s . c om * @param event * @return */ public boolean onKeyDown(int keyCode, KeyEvent event) { if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) && mAudioManager != null) { int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (streamVolume >= mMusicMaxVolume) { LogUtil.d(LogUtil.getLogUtilsTag(BaseFragment.class), "has set the max volume"); return true; } int mean = mMusicMaxVolume / 7; if (mean == 0) { mean = 1; } mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume + mean, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); } if ((event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) && mAudioManager != null) { int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); int mean = mMusicMaxVolume / 7; if (mean == 0) { mean = 1; } mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, streamVolume - mean, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); return true; } return false; }
From source file:net.xisberto.work_schedule.alarm.AlarmMessageActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: stopSound();/*from w w w . j ava2s .c om*/ return true; default: return super.dispatchKeyEvent(event); } }
From source file:com.google.zxing.client.android.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 w w w. ja va2 s.co m finish(); 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); }
From source file:com.jwork.spycamera.MainFragment.java
public boolean onKeyDown(int keyCode, KeyEvent event) { log.v(this, "onKeyDown(keycode:" + keyCode + ")"); if (keyCode == KeyEvent.KEYCODE_BACK) { return controller.pressBack(); } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return controller.pressVolumeDown(); // //TODO // LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutPreview); // linearLayout.removeView(svPreview); // return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return controller.pressVolumeUp(); // //TODO // LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutPreview); // linearLayout.addView(svPreview, 1); // return true; } else if (keyCode == KeyEvent.KEYCODE_MENU) { return controller.pressMenu(); }//from ww w . j av a 2 s. c om return false; }
From source file:uk.org.ngo.squeezer.framework.BaseActivity.java
@Override @CallSuper//from w w w. ja va2s . c om public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: return changeVolumeBy(+5); case KeyEvent.KEYCODE_VOLUME_DOWN: return changeVolumeBy(-5); } return super.onKeyDown(keyCode, event); }
From source file:com.example.castsample.CastSampleActivity.java
/** * Processes volume up and volume down actions upon receiving them as key events. *//*from w w w. ja v a 2 s. c o m*/ @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 - mMPMS==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 - mMPMS==null"); } } return true; default: return super.dispatchKeyEvent(event); } }
From source file:com.stasbar.knowyourself.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); 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_HEADSETHOOK: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_FOCUS: if (!mAlarmHandled && keyEvent.getAction() == KeyEvent.ACTION_UP) { switch (mVolumeBehavior) { case SettingsActivity.VOLUME_BEHAVIOR_SNOOZE: snooze();/*from 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:uk.org.ngo.squeezer.framework.BaseActivity.java
@Override @CallSuper/*www. ja v a 2 s . co m*/ public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: return true; } return super.onKeyUp(keyCode, event); }