How do we know programmatically that the call I am making is received in the other side ? I know that there are some phone states like IDLE, OFFHOOK and RINGING. I want to be notified that the outgoing call I am making is received, is disconnected by the other side or is unattended by the other side.
Please suggest.
What I understand is that we cannot differentiate among the various states inside the OFFHOOK state, unless we have the internal package access.
If we have the internal package access then only we can know whether the call connected is actually received or missed or disconnected by the other side.
you have to use broadcastreceiver with the following onReceive implementation to check for phonestate changes
And if you want to check for intermediate state, you can add e.g. state control in form of an integer ....
You need a PhoneStateListener. With that is is possible to check the state of a phone call. You have to implement
onCallStateChanged
. This method is called every time the state of a phone call changes. Then you can do something like this:Even though there is only three states available in android telephony manager,it is very easy to identify state for all situations in a phone call. So here we are receiving the 3 events from android such as RINGING,OFFHOOK and IDLE. And in order to get the waiting state of a call,we need to define our own states like RINGING, OFFHOOK, IDLE, FIRST_CALL_RINGING, SECOND_CALL_RINGING.
Please think in a way that we are receiving events from android and we will define our on call states.
Here is the method to get call states at onReceive method of broadcast-receiver without registering phonestatelistener and escaping from other complications. See the code.