Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know callee is answered the call (What is the phone state when he lift the call)

Tags:

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?

like image 801
Ramakrishna Avatar asked Jul 17 '12 10:07

Ramakrishna


People also ask

What does it mean when you call someone and your phone says call waiting?

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.

What happens when someone calls me while I'm on a call iPhone?

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.

What does it mean when it says call is waiting?

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.


1 Answers

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

like image 118
Noman Avatar answered Oct 14 '22 06:10

Noman