List of usage examples for android.media AudioManager ADJUST_RAISE
int ADJUST_RAISE
To view the source code for android.media AudioManager ADJUST_RAISE.
Click Source Link
From source file:Main.java
public static final void audioVolumeRaise(Context ctx) { AudioManager audio = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); audio.adjustVolume(AudioManager.ADJUST_RAISE, 0); }
From source file:Main.java
public static void adjustMusicVolume(Context context, boolean up, boolean showInterface) { int direction = up ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER; int flag = AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE | (showInterface ? AudioManager.FLAG_SHOW_UI : 0); getInstance(context).adjustStreamVolume(AudioManager.STREAM_MUSIC, direction, flag); }
From source file:com.glanznig.beepme.view.MainActivity.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_UP) { audioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); }/*from www . j a v a 2 s . co m*/ return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { audioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); } return true; default: return super.dispatchKeyEvent(event); } }
From source file:uk.ac.ucl.excites.sapelli.shared.util.android.DeviceControl.java
/** * Increases the Media Volume//from w w w .ja va 2s .c om * * @param context */ public static void increaseMediaVolume(Context context) { // Get the AudioManager final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Set the volume audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0); }
From source file:com.google.android.marvin.mytalkback.ProcessorVolumeStream.java
private void adjustVolumeFromKeyEvent(int keyCode) { final int direction = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER); if (mTouchingScreen) { mAudioManager.adjustStreamVolume(STREAM_TOUCHING_SCREEN, direction, DEFAULT_FLAGS); } else {/* ww w . ja v a 2 s . c o m*/ // Attempt to adjust the suggested stream, but let the system // override in special situations like during voice calls, when an // application has locked the volume control stream, or when music // is playing. mAudioManager.adjustSuggestedStreamVolume(direction, STREAM_DEFAULT, DEFAULT_FLAGS); } }
From source file:com.dena.app.usage.watcher.MainActivity.java
public boolean onKeyDown(int keyCode, KeyEvent evt) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI); return true; case KeyEvent.KEYCODE_VOLUME_DOWN: mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI); return true; default://from w ww. ja va2s . c o m break; } return super.onKeyDown(keyCode, evt); }
From source file:com.google.android.marvin.talkback.ProcessorVolumeStream.java
private void adjustVolumeFromKeyEvent(int keyCode) { final int direction = ((keyCode == KeyEvent.KEYCODE_VOLUME_UP) ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER); if (mTouchingScreen) { mAudioManager.adjustStreamVolume(STREAM_TOUCHING_SCREEN, direction, DEFAULT_FLAGS_TOUCHING_SCREEN); } else {/* ww w.j a v a 2s . c om*/ // Attempt to adjust the suggested stream, but let the system // override in special situations like during voice calls, when an // application has locked the volume control stream, or when music // is playing. mAudioManager.adjustSuggestedStreamVolume(direction, STREAM_DEFAULT, DEFAULT_FLAGS_NOT_TOUCHING_SCREEN); } }
From source file:com.example.android.miwok.activity.ColorsActivity.java
private AudioManager.OnAudioFocusChangeListener getAudioFocusChangeCallback() { return new AudioManager.OnAudioFocusChangeListener() { Handler mHandler = new Handler(); public void onAudioFocusChange(int focusChange) { // The AUDIOFOCUS_LOSS case means we've lost audio focus permanently if (focusChange == AudioManager.AUDIOFOCUS_LOSS) { // Stop playback and clean up resources releaseMediaPlayer();/* w ww.j av a 2s . c o m*/ } // The AUDIOFOCUS_LOSS_TRANSIENT case means that we've lost audio focus for a // short amount of time. else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) { // Pause playback immediately mMediaPlayer.pause(); // play the word from the beginning when we resume playback. mMediaPlayer.seekTo(0); } //The AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK case means that // our app is allowed to continue playing sound but at a lower volume. else if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) { // Lower the volume, keep playing mAudioManager.adjustVolume(AudioManager.ADJUST_LOWER, 0); } // The AUDIOFOCUS_GAIN case means we have regained focus and can resume playback. else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) { // Raise volume to normal, restart playback if necessary mMediaPlayer.start(); mAudioManager.adjustVolume(AudioManager.ADJUST_RAISE, 0); } } }; }
From source file:com.microsoft.mimickeralarm.appcore.AlarmMainActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { mAudioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { mAudioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND); } else {//from w w w . ja va 2s . c o m return super.onKeyDown(keyCode, event); } return true; }
From source file:com.android.screenspeak.eventprocessor.ProcessorVolumeStream.java
private void adjustVolumeFromKeyEvent(int button) { final int direction = ((button == VolumeButtonPatternDetector.VOLUME_UP) ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER); if (mTouchingScreen) { mAudioManager.adjustStreamVolume(STREAM_TOUCHING_SCREEN, direction, DEFAULT_FLAGS_TOUCHING_SCREEN); } else {/*from www . j a v a 2s.c o m*/ // Attempt to adjust the suggested stream, but let the system // override in special situations like during voice calls, when an // application has locked the volume control stream, or when music // is playing. mAudioManager.adjustSuggestedStreamVolume(direction, STREAM_DEFAULT, DEFAULT_FLAGS_NOT_TOUCHING_SCREEN); } }