I am trying to know how to alert when the callee lifts the call. I have used PhoneStateListener
along with BroadcastReceiver
.
Generally it has three states CALL_STATE_IDLE , CALL_STATE_OFFHOOK, CALL_STATE_RINGING
.
CALL_STATE_OFFHOOK
state was calling when call is connecting, No state of the above three states was called after callee answered
call.
Here is my BroadcastReceiver.
public class PhoneStateBroadcastReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(new CustomPhoneStateListener(context), PhoneStateListener.LISTEN_CALL_STATE);
}
public class CustomPhoneStateListener extends PhoneStateListener
{
Context context; //Context to make Toast if required
ActivityManager activityManager;
public CustomPhoneStateListener(Context context)
{
super();
this.context = context;
}
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
super.onCallStateChanged(state, incomingNumber);
Log.v("PhoneStateBroadcastReceiver", "onCallStateChanged state"+state);
switch (state)
{
case TelephonyManager.CALL_STATE_IDLE:
Toast.makeText(context, "=CALL_STATE_IDLE==", Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Toast.makeText(context, "CALL_STATE_OFFHOOK", Toast.LENGTH_LONG).show();
break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(context, "CALL_STATE_RINGING", Toast.LENGTH_LONG).show();
break;
default:
break;
}
}
}
}
I have seen some applications there are recording a voice when call was accepted. I want to know the state of accepting call.
Is there any other state or listener to know when the callee is answered the call?
If the person you call is on the phone when you call they will receive a tone to indicate to them that there is another call waiting to be answered. They can choose to either put the current call on hold and answer you or ignore it and you will go through to their Voicemail.
If you receive a call on one line while the other is in use for a call, and no Wi-Fi connection is available, iPhone uses the cellular data of the line that's in use for the call to receive the other line's call.
Call waiting is a service you can enable on a mobile or landline phone that, when you're on a phone call, notifies you if you have another phone call incoming and allows you to place your current call on hold to take the second one.
The state will be OFF_HOOK
Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
You can see on this link:
http://developer.android.com/reference/android/telephony/TelephonyManager.html
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