Java Code Examples for android.media.AudioManager#MODE_IN_CALL

The following examples show how to use android.media.AudioManager#MODE_IN_CALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaManager.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
private int getAudioTargetMode() {
	int targetMode = modeSipInCall;
	
	if(service.getPrefs().useModeApi()) {
           Log.d(THIS_FILE, "User want speaker now..." + userWantSpeaker);
		if(!service.getPrefs().generateForSetCall()) {
			return userWantSpeaker ? AudioManager.MODE_NORMAL : AudioManager.MODE_IN_CALL;
		}else {
			return userWantSpeaker ? AudioManager.MODE_IN_CALL: AudioManager.MODE_NORMAL ;
		}
	}
	if(userWantBluetooth) {
	    targetMode = AudioManager.MODE_NORMAL;
	}

	Log.d(THIS_FILE, "Target mode... : " + targetMode);
	return targetMode;
}
 
Example 2
Source File: AutoAnswerReceiver.java    From auto-answer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {

	// Load preferences
	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

	// Check phone state
	String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);

	if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING) && prefs.getBoolean("enabled", false)) {
		// Check for "second call" restriction
		if (prefs.getBoolean("no_second_call", false)) {
			AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
			if (am.getMode() == AudioManager.MODE_IN_CALL) {
				return;
			}
		}			

		// Call a service, since this could take a few seconds
		context.startService(new Intent(context, AutoAnswerIntentService.class));
	}		
}
 
Example 3
Source File: AudioPlayerHandler.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public  void setAudioMode(int mode,Context ctx) {
    if (mode != AudioManager.MODE_NORMAL && mode != AudioManager.MODE_IN_CALL) {
        return;
    }
    AudioManager audioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setMode(mode);
}
 
Example 4
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isOngoingCall() {
    try {
        AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
        // possibly should have MODE_IN_COMMUNICATION as well
    } catch (Exception e) {
        return false;
    }
}
 
Example 5
Source File: JoH.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isOngoingCall() {
    try {
        AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
        // possibly should have MODE_IN_COMMUNICATION as well
    } catch (Exception e) {
        return false;
    }
}
 
Example 6
Source File: SpeechUtil.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
private static boolean isOngoingCall() {
    final AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
    try {
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
    } catch (NullPointerException e) {
        return false;
    }
}
 
Example 7
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isOngoingCall() {
    try {
        AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
        // possibly should have MODE_IN_COMMUNICATION as well
    } catch (Exception e) {
        return false;
    }
}
 
Example 8
Source File: JoH.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isOngoingCall() {
    try {
        AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
        // possibly should have MODE_IN_COMMUNICATION as well
    } catch (Exception e) {
        return false;
    }
}
 
Example 9
Source File: SpeechUtil.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("ConstantConditions")
private static boolean isOngoingCall() {
    final AudioManager manager = (AudioManager) xdrip.getAppContext().getSystemService(Context.AUDIO_SERVICE);
    try {
        return (manager.getMode() == AudioManager.MODE_IN_CALL);
    } catch (NullPointerException e) {
        return false;
    }
}
 
Example 10
Source File: SoundLogic.java    From redalert-android with Apache License 2.0 5 votes vote down vote up
public static int getSoundStreamType(Context context) {
    // Get the audio manager
    AudioManager audioManager = (AudioManager) context.getSystemService(context.AUDIO_SERVICE);

    // In call?
    if (audioManager.getMode() == AudioManager.MODE_IN_CALL) {
        // Play in tiny speaker
        // I think we disabled this because it's played in that speaker already by default
        // return AudioManager.STREAM_VOICE_CALL;
    }

    // Return default stream type
    return Sound.STREAM_TYPE;
}
 
Example 11
Source File: WeatherByVoiceService.java    From your-local-weather with GNU General Public License v3.0 4 votes vote down vote up
private boolean isActiveCall(AudioManager audioManager) {
    return audioManager.getMode() == AudioManager.MODE_IN_CALL;
}
 
Example 12
Source File: Utils.java    From ForceDoze with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isUserInCommunicationCall(Context context) {
    AudioManager manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    return manager.getMode() == AudioManager.MODE_IN_CALL || manager.getMode() == AudioManager.MODE_IN_COMMUNICATION;
}
 
Example 13
Source File: BgToSpeech.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
private boolean isOngoingCall(){
    AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    return (manager.getMode()==AudioManager.MODE_IN_CALL);
}