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:eu.geekgasm.kintrol.DeviceControlActivity.java
@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) { kontrollerThread.increaseVolume(); }/*from w ww. j a va 2 s. co m*/ return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { kontrollerThread.decreaseVolume(); } return true; default: return super.dispatchKeyEvent(event); } }
From source file:com.ekeitho.sound.MainActivity.java
public boolean dispatchKeyEvent(KeyEvent event) { double VOLUME_INCREMENT = 0.05; int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { if (mRemoteMediaPlayer != null) { double currentVolume = Cast.CastApi.getVolume(mApiClient); if (currentVolume < 1.0) { try { Cast.CastApi.setVolume(mApiClient, Math.min(currentVolume + VOLUME_INCREMENT, 1.0)); } catch (Exception e) { Log.e(TAG, "unable to set volume", e); }// w w w . j a v a2 s .c om } } else { Log.e(TAG, "dispatchKeyEvent - volume up"); } } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { if (mRemoteMediaPlayer != null) { double currentVolume = Cast.CastApi.getVolume(mApiClient); if (currentVolume > 0.0) { try { Cast.CastApi.setVolume(mApiClient, Math.max(currentVolume - VOLUME_INCREMENT, 0.0)); } catch (Exception e) { Log.e(TAG, "unable to set volume", e); } } } else { Log.e(TAG, "dispatchKeyEvent - volume down"); } } return true; default: return super.dispatchKeyEvent(event); } }
From source file:com.firefly.sample.castcompanionlibrary.cast.player.VideoCastControllerActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { onVolumeChange((double) mVolumeIncrement); } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { onVolumeChange(-(double) mVolumeIncrement); } else {//from w w w . j a v a2 s . c o m return super.onKeyDown(keyCode, event); } return true; }
From source file:com.bluros.music.activities.BaseActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { return MusicPlayer.volumeKeyAction(false); } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return MusicPlayer.volumeKeyAction(true); }/*from w w w . j a va 2 s. c om*/ return super.onKeyDown(keyCode, event); }
From source file:io.github.hidroh.materialistic.KeyDelegate.java
/** * Calls from {@link Activity#onKeyLongPress(int, KeyEvent)} to delegate * @param keyCode event key code//from w w w. ja va2s .c om * @param event key event * @return true if is intercepted as navigation, false otherwise */ @SuppressWarnings("UnusedParameters") public boolean onKeyLongPress(int keyCode, KeyEvent event) { if (!mEnabled) { return false; } if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { longPress(DIRECTION_UP); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { longPress(DIRECTION_DOWN); return true; } return false; }
From source file:com.coinomi.wallet.ui.ScanActivity.java
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // don't launch camera app return true; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: cameraHandler.post(new Runnable() { @Override/* w w w. ja v a 2s. c o m*/ public void run() { cameraManager.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP); } }); return true; } return super.onKeyDown(keyCode, event); }
From source file:com.syncedsynapse.kore2.ui.RemoteActivity.java
/** * Override hardware volume keys and send to Kodi *//* w ww . jav a 2 s . c o m*/ @Override public boolean dispatchKeyEvent(KeyEvent event) { // Check whether we should intercept this boolean useVolumeKeys = PreferenceManager.getDefaultSharedPreferences(this).getBoolean( Settings.KEY_PREF_USE_HARDWARE_VOLUME_KEYS, Settings.DEFAULT_PREF_USE_HARDWARE_VOLUME_KEYS); if (useVolumeKeys) { int action = event.getAction(); int keyCode = event.getKeyCode(); switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { new Application.SetVolume(GlobalType.IncrementDecrement.INCREMENT) .execute(hostManager.getConnection(), null, null); } return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { new Application.SetVolume(GlobalType.IncrementDecrement.DECREMENT) .execute(hostManager.getConnection(), null, null); } return true; } } return super.dispatchKeyEvent(event); }
From source file:com.audiokernel.euphonyrmt.library.SimpleLibraryActivity.java
@Override public boolean onKeyLongPress(final int keyCode, final KeyEvent event) { boolean result = true; switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: MPDControl.run(MPDControl.ACTION_NEXT); break;//from w ww . j a v a2s . co m case KeyEvent.KEYCODE_VOLUME_DOWN: MPDControl.run(MPDControl.ACTION_PREVIOUS); break; default: result = super.onKeyLongPress(keyCode, event); break; } return result; }
From source file:com.google.android.car.kitchensink.volume.VolumeTestFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.volume_test, container, false); mVolumeList = (ListView) v.findViewById(R.id.volume_list); mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mRefreshButton = (Button) v.findViewById(R.id.refresh); mAdapter = new VolumeAdapter(getContext(), R.layout.volume_item, mVolumeInfos, this); mVolumeList.setAdapter(mAdapter);//from w w w . ja va 2 s .co m mRefreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { initVolumeInfo(); } }); mCarEmulator = CarEmulator.create(getContext()); mCar = mCarEmulator.getCar(); try { mCarAudioManager = (CarAudioManager) mCar.getCarManager(Car.AUDIO_SERVICE); initVolumeInfo(); mCarAudioManager.setVolumeController(mVolumeController); } catch (CarNotConnectedException e) { throw new RuntimeException(e); // Should never occur in car emulator. } mVolumeUp = (Button) v.findViewById(R.id.volume_up); mVolumeDown = (Button) v.findViewById(R.id.volume_down); mVolumeUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mCarEmulator.injectKey(KeyEvent.KEYCODE_VOLUME_UP); } }); mVolumeDown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mCarEmulator.injectKey(KeyEvent.KEYCODE_VOLUME_DOWN); } }); return v; }
From source file:com.kevinshen.beyondupnp.ui.MainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { SystemManager systemManager = SystemManager.getInstance(); if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { int volume = systemManager.getDeviceVolume(); volume += 5;//from w w w .jav a2s. c o m if (volume > 100) volume = 100; sendBroadcast(new Intent(Intents.ACTION_SET_VOLUME).putExtra("currentVolume", volume)); return true; } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { int volume = systemManager.getDeviceVolume(); volume -= 5; if (volume < 0) volume = 0; sendBroadcast(new Intent(Intents.ACTION_SET_VOLUME).putExtra("currentVolume", volume)); return true; } else { return super.onKeyDown(keyCode, event); } }