Code example for AudioManager

Methods: setSpeakerphoneOn

0
 */ 
public class AudioUtils { 
  private static final String TAG = AudioUtils.class.getName();
  public static void enableDefaultRouting(Context context) {
    AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    am.setSpeakerphoneOn(false);
    Log.d(TAG, "Set default audio routing");
 
  } 
 
  public static void enableSpeakerphoneRouting(Context context) {
    AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    am.setSpeakerphoneOn(true);
    Log.d(TAG, "Set speakerphone audio routing");
  } 
 
  public static void resetConfiguration(Context context) {
    enableDefaultRouting(context);
  } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE