Normal Phone Call with Headset plugged possible? - android

I'm facing a Problem, related to my Question: Is it possible to ignore plugged in Headset and still use phone speakers?
I used the same code as in the linked question. The only change here is that I use the PhoneStateListener to intercept when a call is answered and respond to it. This Code is executed, if a Call get's answered:
AudioManager audioManager = (AudioManager) _context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL);
If I add audioManager.setSpeakerphoneOn(true); to it, the loudspeakers are activated (what I don't want)
Nothing happens if I change the AudioManager Mode from AudioManager.MODE_IN_CALL to AudioManager.MODE_IN_COMMUNICATION
My Problem is, that I can't make an "normal" Phone Call, while my Headset is plugged in.
So far I played around with AudioManager and the setMode() function of it.
Unfortunately, the only thing I managed to do was to make a phone call over the loudspeakers. But this is not the desired goal.
Can anyone help me with this?

Related

How to silence incoming call or notification on Android Pie?

My code used to successfully silence incoming calls by simply using setRingerMode, but ever since Android Pie, it's just not working anymore. I had tested the built-in DND mode, and it seemed to not be working either. But if that's true, it's working now, but my code still isn't.
Is there something additional necessary for this to work now? Android Pie does keep a separate mode from DND for ring, vibrate, and silence for ringer sounds, but I haven't been able to find figure out why my code isn't working anymore.
Update:
I'm using the following code:
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
Update (1-23-19):
My understanding is I can't change the notification channel of another app, like the texting or calling app. Does anybody know any differently?

Programmatically muting a call in Android

I am revisiting an old question posted (in early 2014 mind) here:
What permissions are needed to programmatically mute a phone call, from a background app?
How to Mute Phone Call Stream (uplink) while calling on Android
How to mute audio speaker in android
How does setMicrophoneMute() work?
For a recent project, I am building an app that can mute an existing call and get an audio recording from the user. I know that audio-recording in-call works, that's no problem (recording only the user mic). Now i can also reduce the volume programmatically, which i did using the code On my Github, Here
Specifically, I am using the AudioManager class to set the volume to 0 and also muting as a backup, but doesn't work.. I am wondering whether this is a Samsung specific issue or not..
mgr.setStreamVolume(stream, progress, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mgr.adjustVolume(AudioManager.ADJUST_MUTE, AudioManager.FLAG_VIBRATE);
boolean a = mgr.isVolumeFixed();
Log.d("MUTING", "Volume fixed: "+a);
boolean streamMuteStatus = mgr.isStreamMute(stream);
Log.d("MUTING", "Stream Mute Status: "+streamMuteStatus);
I am printing out the boolean variables above for testing purposes, but both print out 'False'.
But the Samsung S5 device is not allowing me to set the volume to 0 at all. This is true even when adjusting the in-call volume using the volume slider.. The slider does not physically move to the leftmost position on the seekbar. See figure below for the leftmost position i can drag to:
Anyone have any ideas about how i can mute the incoming call stream?

Android: Mute ringtone and play custom audio using MediaPlayer

I am not able to mute the incoming call ring tone and play my own media file using MediaPlayer class.
So far I have tried the following in my Activity that pops on top of incoming call screen, started using a BroadcastReceiver; Activity shows up but audio doesn't play:
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.setStreamMute(AudioManager.STREAM_RING,true);
am.setStreamVolume(AudioManager.STREAM_RING, 0, 0);
Then I start playing the audio file. The sound plays perfectly in normal mode, so I also set the audio mode to MODE_NORMAL using am.setMode method but no luck.
Is there any way around? I am currently mobile and so I could not post full code. If anyone has done this before, a block of code would be a great help. Moreover, I dug up the documentation for AudioManager class and found setRoute or similar method which looks good but it has been deprecated long ago so I didn't want to implement it.
Does this approach have different reaults when screen is on or off during an incoming call?

DTMF detection on receiving an incoming call on android

I would like to know whether we could receive the DTMF tones in android.Suppose,i am getting a call,and once i accept the call,is it possible to detect the keys that the other person is pressing during our call.I have go through many stack overflow questions regarding this,but most of them were not providing a solution.
How about implementing it through java reflection or something like that.?All the earlier post were for 2.2 and 3.0 versions.Presently we are in the 4.0 and above,so is it possible in the 4 or above versions?
Thanks in advance
There is no packages to do this in SDK.
FIRST, you need to listen the speaker voice, because you can not record voice call :
AudioManager mAudioManager = (AudioManager) Sos.getContext().getSystemService(Context.AUDIO_SERVICE);
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, maxVolume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
mAudioManager.setSpeakerphoneOn(true);
AND, this project may help you :
http://code.google.com/p/dtmf-decoder/source/checkout
I've done this, so i know it is possible this way.
Good luck

AudioManager - difference between two methods

What is the difference between calling AudioManager.setRingerMode to calling AudioManager.setStreamMute(AudioManager.STREAM_VOICE_CALL, ...)
What does the documentation mean by "Ringer mode"? I'm pretty sure it is the phone ringer mode. Then how does it differ from calling setStreamMute with STREAM_VOICE_CALL?
If it is not the phone ringer mode, then what is it?
Thanks in advance.
I have never used the audio stream on the android platform, however, based on reading the documentation, I think setRingerMode will affect how the phone reacts to incoming calls. For example, AudioManager.setRingerMode(RINGER_MODE_SILENT) will disable vibrations and sound when an incoming call is received.
However, AudioManager.setStreamMute seems to control more than just the audio stream for phone rings.
From the documentation at http://developer.android.com/reference/android/media/AudioManager.html#STREAM_VOICE_CALL
I think that AudioManager.setRingerMode(RINGER_MODE_SILENT) will act the same way as AudioManager.setStreamMute(STREAM_RING, true).
I think the best way to see what the difference is (nd to see if what I am saying is true) would be to write a small program that tests the two features.

Categories

Resources