Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out going call answered state in Android 2.2+

Tags:

android

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.

like image 678
Yugandhar Babu Avatar asked Nov 13 '22 14:11

Yugandhar Babu


1 Answers

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.

like image 188
Jong Avatar answered Nov 15 '22 05:11

Jong