Android examples for Media:Auto Player
Close Speaker for audio
//package com.java2s; import android.content.Context; import android.media.AudioManager; public class Main { private static int currVolume = 0; public static void CloseSpeaker(Context context) { try {//from w w w . j ava 2s . c o m AudioManager audioManager = (AudioManager) context .getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { if (audioManager.isSpeakerphoneOn()) { audioManager.setSpeakerphoneOn(false); audioManager.setStreamVolume( AudioManager.STREAM_VOICE_CALL, currVolume, AudioManager.STREAM_VOICE_CALL); } } } catch (Exception e) { e.printStackTrace(); } } }