6

I am initiating a voice call from my application. Now i want that when the user on the other side picks up the call, i want to play a recorded audio file.

How to go about this? Please help!

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Shafi
  • 1,368
  • 10
  • 24

2 Answers2

6

I have found a workaround with this. I play an audio file on device's speakers with full sound when the phone state changes to TelephonyManager.CALL_STATE_OFFHOOK

This ensures that the user on the other side can hear the recording.

Shafi
  • 1,368
  • 10
  • 24
  • 1
    +1 for nice question and answer also. I also integrate the same task in my application but i need extra information on this. Please help me on this. my need is "Suppose we have recorded file in our mobile,when we call to any person,as soon as he picked up the call he should listen recorded voice file,which we have recorded". Please replay me as soon as possible. Thank you. – Ramakrishna Jan 02 '12 at 13:44
  • @Shafi , can you please provide me the road map to implement solution the way you have suggested – Hunt Apr 10 '12 at 06:07
  • @Ramakrishna Thanks. My requirement was also the same as yours, and i used the solution that i mentioned. – Shafi Jul 24 '12 at 12:49
  • @Hunt You can listen to the phone state changes in Android. Just extend your class with PhoneStateListener and override the method onCallStateChanged. This is the method where you must write your logic. Hope this helps. – Shafi Jul 24 '12 at 12:56
  • Well i tried this but in that case songs play to my end only :( – Hunt Jul 24 '12 at 14:49
  • Correct me if i am wrong. Do you mean, when the receiver disconnects the phone, your song should stop? I am sure you can do it using the broadcast intent ACTION_PHONE_STATE_CHANGED under Telephony Manager. For more specific implementations, you might want to play around with phone states, as done in this thread. http://stackoverflow.com/questions/9684866/how-to-detect-when-phone-is-answered-or-rejected – Shafi Jul 25 '12 at 13:18
  • @Shafi Thanks for your response. I have completed that task but small problem. can you check this question http://stackoverflow.com/questions/11520590/how-to-know-callee-is-answered-the-call-what-is-the-phone-state-when-he-lift-th – Ramakrishna Jul 26 '12 at 05:59
  • hey you able to play a recorded sound in speaker or mic during a call..?.if u done then please help me .i want to play audio file after incoming call received .please help me,how to do this? – Mayuri Oct 02 '15 at 06:36
2

In simple and clear words you cant stream any sound on an Incoming call

ingsaurabh
  • 15,249
  • 7
  • 52
  • 81