List of usage examples for android.content Context AUDIO_SERVICE
String AUDIO_SERVICE
To view the source code for android.content Context AUDIO_SERVICE.
Click Source Link
From source file:Main.java
public static void openSpeaker(Context context, boolean on) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (on) {/*from w w w.j a v a 2 s .c om*/ audioManager.setMode(AudioManager.MODE_NORMAL); audioManager.setSpeakerphoneOn(true); } else { audioManager.setSpeakerphoneOn(false); } }
From source file:Main.java
public static void mute(Context context) { if (audioManager == null) { audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); }//from www . j a va 2 s .c o m audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true); audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true); }
From source file:Main.java
/** * Call checker/*w ww .j av a2s.c o m*/ * @param context * @return true if a call is going on. */ public static boolean isACallActive(Context context) { AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (manager.getMode() == AudioManager.MODE_IN_CALL) { return true; } else { return false; } }
From source file:Main.java
public static int getMaxSpeakerVolume(Context context) { if (context == null) { return -1; }/*www .j av a 2s.com*/ int level = -1; AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { level = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); } return level; }
From source file:Main.java
public static void setCurrentRingerMode(Context context) { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL) { currentMode = AudioManager.RINGER_MODE_NORMAL; currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_RING); Log.i("Current Mode Normal", currentVolume + ""); Log.i("Vlaue of", currentMode + ""); } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) { currentMode = AudioManager.RINGER_MODE_VIBRATE; Log.i("Current Mode Vibrate", currentVolume + ""); Log.i("Vlaue of", currentMode + ""); } else if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { currentMode = AudioManager.RINGER_MODE_SILENT; Log.i("Current Mode Silent", currentVolume + ""); Log.i("Vlaue of", currentMode + ""); } else {//from www . j a va 2 s . co m Log.i("Nothing ", "Matched above"); } }
From source file:Main.java
public static int getVivaVolume(Context context) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); int amStreamMusicVol = am.getStreamVolume(AudioManager.STREAM_MUSIC); return getPreferences(context).getInt(VivaVolume, amStreamMusicVol); }
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 setRingVolume(Context context, int ringVloume) { if (ringVloume < 0) { ringVloume = 0;/*w ww . j a v a 2 s .com*/ } else if (ringVloume > 7) { ringVloume = ringVloume % 7; if (ringVloume == 0) { ringVloume = 7; } } ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING, ringVloume, AudioManager.FLAG_PLAY_SOUND); }
From source file:Main.java
private static AudioManager getAudioManager(Context context) { return (AudioManager) context.getApplicationContext().getSystemService(Context.AUDIO_SERVICE); }
From source file:Main.java
public static AudioManager getAudioManager(Context context) { return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); }