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;
Piping audio into a phone call is completely unsupported by Android hardware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With