List of usage examples for android.view KeyEvent KEYCODE_VOLUME_UP
int KEYCODE_VOLUME_UP
To view the source code for android.view KeyEvent KEYCODE_VOLUME_UP.
Click Source Link
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);// ww w. j av a 2s .c o m } 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 w w w . jav 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:com.marvin.rocklock.RockLockActivity.java
/** * Pick up back button and volume up and down *//*from www .ja v a 2 s . c om*/ @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:org.jitsi.android.gui.call.VideoCallActivity.java
/** * {@inheritDoc}/* w w w. java2 s.c om*/ */ @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: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;/*ww w .j ava 2 s. c o m*/ default: return super.onKeyDown(keyCode, event); } return true; }
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 .ja v a 2 s . co 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); }
From source file:com.google.fpl.voltair.VoltAirActivity.java
/** * @brief Called to process (and possibly intercept) key events. * @param event @c KeyEvent to handle//from w ww. j a v a2s . co m * @returns @c true if @p event was handled */ @Override public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { // Since QtActivity does not handle volume (throwing the events on the floor) and we // cannot call super.super, we must handle managing of the volume here // TODO: Figure out how to get the volume Ui slide to show up without permanently // breaking immersive mode. switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0 /* No flags */); break; case KeyEvent.KEYCODE_VOLUME_DOWN: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, 0 /* No flags */); break; } } // QtActivity (i.e. super) will convert all key events to QKeyEvents and *always* return // true saying it accepted the event -- even on Gamepad key events it doesn't understand. // This is annoying, and unfortunately means that we must always let controllers take a look // at the event even if QtActivity understood it and accepted it for use (e.g. in the UI). // However, we must be careful with events that are successfully translated (e.g. Keyboard // key events) so as to not spawn two separate controllers (one here with the Android // KeyEvent, and the other one in "InputArea" with the translated QKeyEvent). if (isGamepadEvent(event)) { if (onGamepadKeyEvent(event)) { return true; } } else if (isTouchNavigationEvent(event)) { if (onTouchNavigationKeyEvent(event)) { return true; } } else if (isKeyboardEvent(event)) { if (onKeyboardKeyEvent(event)) { return true; } } return super.dispatchKeyEvent(event); }
From source file:org.ulteo.ovd.AndRdpActivity.java
@Override public boolean dispatchKeyEvent(KeyEvent event) { AudioManager audioManager;/*ww w. j a v a2 s .c o m*/ if (Config.DEBUG) Log.i(Config.TAG, "AndRdpActivity.dispatchKeyEvent " + event); // Disable keypress if it is from a mouse or touchpad. if (event.getDeviceId() >= 0) { InputDevice dev = InputDevice.getDevice(event.getDeviceId()); if (dev.getSources() == InputDevice.SOURCE_MOUSE || dev.getSources() == InputDevice.SOURCE_TOUCHPAD) return true; } if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MENU: OnThreeFingers(null); return true; case KeyEvent.KEYCODE_BACK: Log.i(Config.TAG, "Back key pressed"); askLogoutDialog(); return true; case KeyEvent.KEYCODE_VOLUME_UP: audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; } } else if (event.getAction() == KeyEvent.ACTION_UP) { switch (event.getKeyCode()) { case KeyEvent.KEYCODE_MENU: case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: return true; } } if (isLoggedIn() && rdp.dispatchKeyEvent(event)) return true; return super.dispatchKeyEvent(event); }
From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java
/** * This function accesses the hardware buttons (like volume buttons). We need this access, * because shutter remotes emulate such a key press over bluetooth. * @param keyCode//from w w w. j a v a 2s. co m * @param event * @return */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { takePicture(); } else if (keyCode == KeyEvent.KEYCODE_BACK) { super.onBackPressed(); } return true; }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.AppsViewFragment.java
@Override public boolean onKeyLongPress(int keyCode, KeyEvent event) { /*if (!MusubiBaseActivity.getInstance().isDeveloperModeEnabled()) { return false;// w ww .j a v a2 s .c o m }*/ if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { Intent record = new Intent(getActivity(), VoiceQuickRecordActivity.class); record.putExtra("feed_uri", mFeedUri); record.putExtra("keydown", true); startActivity(record); return true; } if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { Intent camera = new Intent(getActivity(), PhotoQuickTakeActivity.class); camera.putExtra("feed_uri", mFeedUri); startActivity(camera); return true; } return false; }