List of usage examples for android.media AudioManager setStreamVolume
public void setStreamVolume(int streamType, int index, int flags)
From source file:Main.java
public static void setVolume(int volume, Context context) { AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); manager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); }
From source file:Main.java
public static void setVolume(Context context, int volume) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_PLAY_SOUND); }
From source file:Main.java
public static void setVivaVolume(Context context, int volume) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); getPreferences(context).edit().putInt(VivaVolume, volume).apply(); }
From source file:Main.java
public static void setStreamVolume(Context context, int streamType, int volume, int flag) { AudioManager audioManager = getAudioManager(context); if (audioManager == null) return;/*from w w w. java2s .com*/ audioManager.setStreamVolume(streamType, volume, flag); }
From source file:Main.java
private static void setVolume(AudioManager manager, int audioStream, int setValue) { int volume = manager.getStreamMaxVolume(audioStream) * setValue / 100; manager.setStreamVolume(audioStream, volume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE); }
From source file:Main.java
public static void silentAlarm(Context context) { if (player != null) { Log.i("AlarmHelper", "silented"); try {/* www.j a va 2 s .c o m*/ if (player.isLooping()) { player.setLooping(false); } player.pause(); player.stop(); player.release(); } catch (IllegalStateException e) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); } // player.setVolume(0, 0); AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, mUserVolume, 0); } else { Log.i("AlarmHelper", "ring zero"); AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); } if (vibrator != null) { vibrator.cancel(); } else { vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibrator.cancel(); } }
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 setVoice(Context context, int voice) { AudioManager audioManager = (AudioManager) context.getSystemService(Service.AUDIO_SERVICE); // audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, voice, 0); audioManager.setStreamVolume(AudioManager.STREAM_ALARM, voice, 0); }
From source file:Main.java
public static void setRinger2Normal(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); //setting the volume audioManager.setStreamVolume(AudioManager.STREAM_RING, currentVolume, 0); Log.i("HelperFunctions ", "Normal method called"); }
From source file:Main.java
public static void setAudioManage(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true); audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true); audioManager.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); audioManager.setStreamVolume(AudioManager.STREAM_DTMF, 0, 0); audioManager.setStreamVolume(AudioManager.STREAM_NOTIFICATION, 0, 0); audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0); }