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
Related
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?
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?
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?
I have create the aidl file ITelephony.aidl for ending the call. Now before the call should be ended, I need to generate the voice in ongoing call, so that the listener assumes that there is a problem in next work.
I have tried to solve this by myself in three ways:
Control the audio stream volume
audioManager.setStreamMute(AudioManager.STREAM_VOICE_CALL, isMute);
int index = rand.nextInt(5);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,index,0);
Another way is using the setMute in telephonyService
http://androidsourcecode.blogspot.in/2010/10/blocking-incoming-call-android.html
but working in in 2.3
I have also tried to implement using media player for start playing when the call is going on but no luck.
So if there is any other idea then please let me know.
It seems you have the same problem I had a while ago: With Android 2.3 aka Gingerbread it's no longer possible to use the ITelephony interface because the MODIFY_PHONE_STATE permission has been marked system only.
Details may be found here.
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.