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:com.wso2.mobile.mdm.services.Operation.java
/** * Mute the device// ww w . j ava 2 s . c om */ private void muteDevice() { Log.v("MUTING THE DEVICE : ", "MUTING"); AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); Log.v("VOLUME : ", "" + audioManager.getStreamVolume(AudioManager.STREAM_RING)); audioManager.setStreamVolume(AudioManager.STREAM_RING, 0, 0); Log.v("VOLUME AFTER: ", "" + audioManager.getStreamVolume(AudioManager.STREAM_RING)); }
From source file:org.botlibre.sdk.activity.ChatActivity.java
private void muteMicBeep(boolean mute) { debug("muteMicBeep:" + mute + ":" + MainActivity.volume); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (mute) {/*ww w . j a v a 2 s . c o m*/ //if its true then the Volume will be zero. audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); } else { //if its false, the Volume will put back on audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, MainActivity.volume, 0); } }
From source file:com.kaichaohulian.baocms.ecdemo.ui.chatting.ChattingFragment.java
private void initToneGenerator() { AudioManager mAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE); if (mToneGenerator == null) { try {//from www . ja v a 2 s .c om int streamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC); int streamMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int volume = (int) (TONE_RELATIVE_VOLUME * (streamVolume / streamMaxVolume)); mToneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, volume); } catch (RuntimeException e) { LogUtil.d("Exception caught while creating local tone generator: " + e); mToneGenerator = null; } } }
From source file:org.botlibre.sdk.activity.ChatActivity.java
private void setStreamVolume() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); if (volume != 0) { debug("setStreamVolume:" + volume); Log.d("ChatActivity", "The volume changed and saved to : " + volume); MainActivity.volume = volume;// w w w .ja v a 2 s . co m } }
From source file:com.android.launcher3.Utilities.java
public static void modeSilent(Activity activity) { checkPermissionForRingtone(activity); AudioManager mobilemode = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); if (isModeSilent) { mobilemode.setRingerMode(mobileModeSilentPrevious); isModeSilent = false;//from w w w. ja va 2 s . co m } else { isModeSilent = true; mobileModeSilentPrevious = mobilemode.getRingerMode(); mobilemode.setRingerMode(AudioManager.RINGER_MODE_SILENT); } }
From source file:com.youku.player.base.YoukuBasePlayerActivity.java
private void initSound() { am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); currentSound = am.getStreamVolume(AudioManager.STREAM_MUSIC); }
From source file:com.android.launcher3.Utilities.java
public static void modeVibrate(Activity activity) { checkPermissionForRingtone(activity); AudioManager mobilemode = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); if (isModeVibrate) { mobilemode.setRingerMode(mobileModeVibratePrevious); isModeVibrate = false;//w ww . j a v a 2 s . c o m } else { isModeVibrate = true; mobileModeVibratePrevious = mobilemode.getRingerMode(); mobilemode.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); } }
From source file:com.android.launcher3.Utilities.java
public static void modeNormal(Activity activity) { checkPermissionForRingtone(activity); AudioManager mobilemode = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); if (isModeNormal) { mobilemode.setRingerMode(mobileModeNormalPrevious); isModeNormal = false;//ww w . j a v a 2s . c om } else { isModeNormal = true; mobileModeNormalPrevious = mobilemode.getRingerMode(); mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL); } }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
protected void muteAllSounds() { ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_ALARM, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_DTMF, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_MUSIC, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_NOTIFICATION, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_RING, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_SYSTEM, true); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_VOICE_CALL, true); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_DTMF, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_VOICE_CALL, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_DTMF, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_RING, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_SYSTEM, AudioManager.ADJUST_MUTE, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).adjustStreamVolume(AudioManager.STREAM_VOICE_CALL, AudioManager.ADJUST_MUTE, 0); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
protected void unmuteAllSounds() { ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_ALARM, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_DTMF, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_MUSIC, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_NOTIFICATION, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_RING, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_SYSTEM, false); ((AudioManager) ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)) .setStreamMute(AudioManager.STREAM_VOICE_CALL, false); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_ALARM, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_DTMF, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_RING, 0, 0); // ((AudioManager)ApplicationScreen.instance.getSystemService(Context.AUDIO_SERVICE)).setStreamVolume(AudioManager.STREAM_SYSTEM, 0, 0); }