5

In my application I initiated an outgoing call and I am using PhoneStateListener to know about call state.

Whenever I start making call the phone state is TelephonyManager.CALL_STATE_OFFHOOK. When call recipient answered the call, I am not getting any change in phone's state.

I tried many but failed to get this answered state. Somebody told use bluetooth's HFP (Hands Free Profile) to get call answered state. But I didn't get any information about HFP from android developers website.

If anybody faced same problem and got the solution, please give your valuable suggestions.

Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67

3 Answers3

1

The CALL_STATE_OFFHOOK doesn't change when the call is answered by the recepient:

Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.

The state shouldn't change as long as the phone is in call, whether it's answered or not.

This question had been asked many items, and so far none of the those I found have been solved: Detect if an outgoing call has been answered, Android : How to get a state that the outgoing call has been answered?, Android : How to get a state that the outgoing call has been answered? (There are many others). The solutions provided there rely on the CALL_STATE_OFFHOOK state to change when the call is answered, which doesn't happen.

Seems like there is no public API which can be used to get the outgoing call state. The best workaround I see is what Vivek Khandelwal suggested., it's not so long to code nor has heavy performance overheads. Unless adding too many permissions (Now you need to add READ_CALL_LOGS) is a problem, use it.

Community
  • 1
  • 1
Jong
  • 9,045
  • 3
  • 34
  • 66
0

I too had the same problem. This may not be the answer for your question. I am just sharing what I did.

I had an activity which opens the Contact and can make a call. What I wanted is, to known whether the call was successful (i.e recipient answered to the call).

There was no solution i found at that time with PhoneStateListener.

So as a work around, what I did is checked the Call Logs if it has a outgoing call to the phone numbers of that contact after starting the Contact Activity.

See if his help.

Vivek Khandelwal
  • 7,829
  • 3
  • 25
  • 40
  • I heard this, but when we have to check call logs ? Is there any call log change listener or some thing like that ? – Yugandhar Babu Dec 19 '12 at 09:28
  • check this if it could help you http://stackoverflow.com/questions/4422410/how-to-implement-a-contentobserver-for-call-logs – Vivek Khandelwal Dec 19 '12 at 09:38
  • This won't work. The call log will still log a duration starting from the time the phone is dialed. You cannot distinguish between the dialing time and answered state. There is currently no solution to determine if a call has been answered. – Johann Mar 06 '13 at 06:58
0

you want something specific to bluetooth? Otherwise I can provide sources

letroll
  • 1,059
  • 1
  • 14
  • 36