7

I want to develop an application through which if the caller calls you, the call should be answered automatically without user's involvement and the caller could hear a pre-recorded voice which is already recorded and saved.The audio file should be in .wav format.I searched for help in google but i came to know that it is not possible in Android but there are some android applications which have the same functionality.So i think there is some possibility for this.Excuse me if the question is wrong.I would be grateful if some one help me.I am using eclipse Helios with ADT Plugin. I've tried the below code but it didn't work out.If someone know the answer please help me out. I've used broadcast receiver to read the phone state changes.In CALL_STATE_OFFHOOK, i wrote the following code.

case TelephonyManager.CALL_STATE_OFFHOOK:
Toast.makeText(context, "Call Picked..", Toast.LENGTH_LONG) .show();
Log.d("received", "Call Picked....");
final MediaPlayer mPlayer = MediaPlayer.create(context, R.raw.music_file);
                    mPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
                    mPlayer.prepareAsync();
                    mPlayer.start();
                    mPlayer.setOnErrorListener(new OnErrorListener() {

                        @Override
                        public boolean onError(MediaPlayer mp, int what, int extra) {
// TODO Auto-generated method 
mPlayer.reset();
                            return true;
                        }
                    });
                    AudioManager am=(AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
                    am.setMode(AudioManager.MODE_IN_CALL);
                    am.setSpeakerphoneOn(false);
                    am.setMicrophoneMute(true);
                    Log.d("in call","sent audio");
                    mPlayer.reset();
                    mPlayer.release();
                    break; 
Renjith
  • 5,783
  • 9
  • 31
  • 42
kishwar
  • 101
  • 2
  • 5
  • Not tried to implement that yet - just doing a little research. As far as I can understand it is possible! Think for a minute about all the Bluetooth speakers and stuff like that. They are transferring a sound to the phone in call. Right now I need this functionality as well. I'll try to figure it out. – Yura Sokolov Oct 31 '13 at 13:40
  • @YuraSokolov, have you found anything yet? Would really appreciate if you could update us on that :) – longwalker Nov 25 '14 at 12:54
  • Nope, sorry @longwalker, I was unable to find the solution. – Yura Sokolov Nov 26 '14 at 13:47
  • @Kishwar did you manage to find a solution for this? – Silvia H May 02 '15 at 18:13

2 Answers2

3

Piping audio into a phone call is completely unsupported by Android hardware.

MarsAtomic
  • 10,436
  • 5
  • 35
  • 56
  • 2
    Or rather, unsupported by _software_. There are hardware platforms (fairly common ones) used by Android phones that support call uplink injection. But there's no API for it in Android (neither a Java API nor a native one) so there's no way for applications to make use of it. – Michael Apr 30 '13 at 11:01
  • 1
    I completely agree with you MarsAtomic and Michael. But there are some android applications in Google Play store which do the same functionality. If it is not possible how would that applications work. Please help me out as i am new to android and i have to do the same project. Thanks in advance. – kishwar Apr 30 '13 at 11:32
  • Crank the volume of your sound file to maximum so that the microphone picks it up. That's as much as you can do as far as I know. – MarsAtomic Apr 30 '13 at 21:17
0

"Auto Call Answer" by DevIndia Infoway is on the playstore. It works by playing back an mp3 while switching the handsfree on. So the other party will hear what is played (and also if there is other noise in the room). Not really rocket-science.

Ranbir
  • 81
  • 1
  • 2
  • Can we reverse engineer that application? Can anyone please tell me how can i reverse engineer that application? I want to know the code to implement that functionality. – kishwar May 10 '13 at 12:12
  • @kishwar you can do reverse engineering using **dex2jar** converter available free of cost. using **dex2jar** you will get jar file that can be further converted into java class using **jd-gui** tool. Remember by using **dex2jar** only java file can be achieved if you want resource and manifest also then use **apktool**. – arvindsingh530 Mar 30 '14 at 13:18