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:lenidh.android.holochron.ui.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_DOWN: this.onVolumeDown(); return true; case KeyEvent.KEYCODE_VOLUME_UP: this.onVolumeUp(); return true; }//from w ww .j a v a 2 s . c om return super.onKeyDown(keyCode, event); }
From source file:freed.cam.ActivityFreeDcamMain.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (activityIsResumed) { Log.d(TAG, "KeyCode Pressed:" + keyCode); int appSettingsKeyShutter = 0; if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER).equals(StringUtils.VoLP)) appSettingsKeyShutter = KeyEvent.KEYCODE_VOLUME_UP; else if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER) .equals(StringUtils.VoLM)) appSettingsKeyShutter = KeyEvent.KEYCODE_VOLUME_DOWN; else if (getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER) .equals(StringUtils.Hook) || getAppSettings().getApiString(AppSettingsManager.SETTING_EXTERNALSHUTTER).equals("")) appSettingsKeyShutter = KeyEvent.KEYCODE_HEADSETHOOK; if (keyCode == KeyEvent.KEYCODE_3D_MODE || keyCode == KeyEvent.KEYCODE_POWER || keyCode == appSettingsKeyShutter || keyCode == KeyEvent.KEYCODE_UNKNOWN || keyCode == KeyEvent.KEYCODE_CAMERA) { cameraFragment.GetModuleHandler().DoWork(); return true; }//from ww w . java 2s .c o m if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { closeActivity(); return true; } } return super.onKeyDown(keyCode, event); }
From source file:zxing.util.CaptureActivity.java
License:asdf
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Intent intent = new Intent(); if (lastResult != null) { intent.putExtra("BarCode", lastResult); setResult(RESULT_OK, intent); finish();//from w ww .jav a 2 s .c o m return true; } else { restartPreviewAfterDelay(0L); 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); }
From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) || (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) { // capture event to suppress android system sound return true; }//from ww w . j ava 2s.c o m return super.onKeyUp(keyCode, event); }
From source file:com.darly.im.ui.CCPActivityBase.java
/** * * @param keyCode/*from w ww. ja v a2 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:com.sveder.cardboardpassthrough.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) && activado == false) { activado = true;/*from w ww . j a va2 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:org.madmatrix.zxing.android.CaptureActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: // ? if ((source == IntentSource.NONE) && lastResult != null) { restartPreviewAfterDelay(0L); return true; }//from w ww . j a v a 2 s .c om 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.fatelon.flyingphotobooth.fragments.CaptureFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final LaunchActivity activity = (LaunchActivity) getActivity(); SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(activity.getApplicationContext()); /*/*from ww w . ja v a2s. c om*/ * Reset frames. */ String numPhotosPref = preferences.getString(getString(R.string.pref__number_of_photos_key), getString(R.string.pref__number_of_photos_default)); mFramesTotal = Integer.parseInt(numPhotosPref); mFrameIndex = 0; mFramesData = new byte[mFramesTotal][]; /* * Initialize and set key event handlers. */ mBackPressedHandler = new LaunchActivity.BackPressedHandler() { @Override public boolean onBackPressed() { // If capture sequence is running, exit capture sequence on back pressed event. if (mIsCaptureSequenceRunning) { activity.replaceFragment(CaptureFragment.newInstance(mUseFrontFacing), false, true); } return mIsCaptureSequenceRunning; } }; activity.setBackPressedHandler(mBackPressedHandler); mKeyEventHandler = new LaunchActivity.KeyEventHandler() { @Override public boolean onKeyEvent(KeyEvent event) { final int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mStartButton.dispatchKeyEvent(event); return true; } return false; } }; activity.setKeyEventHandler(mKeyEventHandler); /* * Functionalize views. */ mPreferencesButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent preferencesIntent = new Intent(activity, MyPreferenceActivity.class); startActivity(preferencesIntent); } }); // Show switch button only if more than one camera is available. if (mNumCameras > 1) { mSwitchButton.setVisibility(View.VISIBLE); mSwitchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Switch camera. boolean useFrontFacing = false; CameraInfo cameraInfo = new CameraInfo(); if (mCameraId != INVALID_CAMERA_ID) { Camera.getCameraInfo(mCameraId, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { useFrontFacing = true; } // Relaunch fragment with new camera. activity.replaceFragment(CaptureFragment.newInstance(useFrontFacing), false, true); } } }); } // Get trigger mode preference. String triggerPref = preferences.getString(getString(R.string.pref__trigger_key), getString(R.string.pref__trigger_default)); if (triggerPref.equals(getString(R.string.pref__trigger_countdown))) { mTriggerMode = TRIGGER_MODE_COUNTDOWN; } else if (triggerPref.equals(getString(R.string.pref__trigger_burst))) { mTriggerMode = TRIGGER_MODE_BURST; } else { mTriggerMode = TRIGGER_MODE_MANUAL; } // Configure title and start button text. mTitle.setText(String.format(getString(R.string.capture__title_frame), mFrameIndex + 1, mFramesTotal)); if (mTriggerMode == TRIGGER_MODE_MANUAL) { // Update title. mStartButton.setText(getString(R.string.capture__start_manual_button_text)); } else { mStartButton.setText(getString(R.string.capture__start_countdown_button_text)); } // Configure start button behaviour. mStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onStartButtonPressedImpl(); } }); mStartButton.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { onStartButtonPressedImpl(); return true; } }); }
From source file:com.example.castsample.CastSampleActivity.java
/** * Processes volume up and volume down actions upon receiving them as key events. *//*from w ww .j a v a2 s. c om*/ @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: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;/*from w ww.j a v a2 s .co 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); }