List of usage examples for android.media AudioManager FLAG_SHOW_UI
int FLAG_SHOW_UI
To view the source code for android.media AudioManager FLAG_SHOW_UI.
Click Source Link
From source file:Main.java
public static void setCurrentVolume(int percent, Context mc) { AudioManager am = (AudioManager) mc.getSystemService(Context.AUDIO_SERVICE); int maxvolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC); am.setStreamVolume(AudioManager.STREAM_MUSIC, (maxvolume * percent) / 100, AudioManager.FLAG_PLAY_SOUND | AudioManager.FLAG_SHOW_UI); am.setMode(AudioManager.MODE_INVALID); }
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.darly.im.ui.BaseFragment.java
/** * ?,??/*from ww w . jav a 2s .com*/ * @param keyCode * @param event */ @Override 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); return true; } 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 super.onKeyDown(keyCode, event); }
From source file:com.gao.im.ui.BaseFragment.java
/** * ?,??//from www .java 2s .c om * @param keyCode * @param event */ 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); return true; } 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 super.onKeyDown(keyCode, event); }
From source file:net.hyx.app.volumenotification.factory.NotificationFactory.java
public void setVolume(int id) { int type = getStreamType(id); audio.adjustStreamVolume(type, getStreamFlag(type), AudioManager.FLAG_SHOW_UI); }
From source file:net.hyx.app.volumenotification.NotificationFactory.java
void setVolume(int position) { int selection = settings.getButtonSelection(position); int direction = AudioManager.ADJUST_SAME; int type = STREAM_TYPES[selection]; if (type == AudioManager.STREAM_MUSIC && settings.getToggleMute()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { direction = AudioManager.ADJUST_TOGGLE_MUTE; } else {//from w w w . j a v a2 s. co m _mute = !_mute; audio.setStreamMute(type, _mute); } } else if (type == AudioManager.STREAM_RING && settings.getToggleSilent()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { direction = AudioManager.ADJUST_TOGGLE_MUTE; } else { _silent = !_silent; audio.setStreamMute(type, _silent); } } audio.adjustStreamVolume(type, direction, AudioManager.FLAG_SHOW_UI); }
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 w w w . j a va 2 s .c o 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: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 w w . ja v a 2s . c o m break; } return super.onKeyDown(keyCode, evt); }
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 ww w . j a v a 2s. com*/ return super.onKeyDown(keyCode, event); } return true; }
From source file:dk.dr.radio.afspilning.Afspiller.java
/** Srg for at volumen er skruet op til en minimumsvrdi, angivet i 5'tedele af fuld styrke */ public void tjekVolumenMindst5tedele(int min5) { int max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int nu = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (nu < min5 * max / 5) { audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, min5 * max / 5, AudioManager.FLAG_SHOW_UI); }//from w w w . jav a 2 s . c o m }