Example usage for android.media AudioManager getRouting

List of usage examples for android.media AudioManager getRouting

Introduction

In this page you can find the example usage for android.media AudioManager getRouting.

Prototype

@Deprecated
public int getRouting(int mode) 

Source Link

Document

Returns the current audio routing bit vector for a specified mode.

Usage

From source file:com.phonegap.AudioHandler.java

/**
 * Get the audio device to be used for playback.
 * /*from w ww.j  a v  a  2  s.c o  m*/
 * @return               1=earpiece, 2=speaker
 */
public int getAudioOutputDevice() {
    AudioManager audiMgr = (AudioManager) this.ctx.getSystemService(Context.AUDIO_SERVICE);
    if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) {
        return 1;
    } else if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) {
        return 2;
    } else {
        return -1;
    }
}

From source file:org.skt.runtime.additionalapis.AudioHandler.java

/**
 * Get the audio device to be used for playback.
 *
 * @return               1=earpiece, 2=speaker
 *///  w  ww  .  j  a v  a2s. co m
@SuppressWarnings("deprecation")
public int getAudioOutputDevice() {
    AudioManager audiMgr = (AudioManager) this.ctx.getSystemService(Context.AUDIO_SERVICE);
    if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) {
        return 1;
    } else if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) {
        return 2;
    } else {
        return -1;
    }
}

From source file:com.commontime.cordova.audio.AudioHandler.java

/**
 * Get the audio device to be used for playback.
 *
 * @return               1=earpiece, 2=speaker
 *///from   w  ww .j av  a2  s.  c  o  m
@SuppressWarnings("deprecation")
public int getAudioOutputDevice() {
    AudioManager audiMgr = (AudioManager) this.cordova.getActivity().getSystemService(Context.AUDIO_SERVICE);
    if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_EARPIECE) {
        return 1;
    } else if (audiMgr.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER) {
        return 2;
    } else {
        return -1;
    }
}