How can I detect missing call when there's a call in progress

36 Views Asked by At

I have a call recorder app and it works fine but I have a case If there's a call in progress and a new call received I can't catch if it's missed or answered

        @Override
        public void onReceive(Context context, Intent intent) {
               if (intent != null && intent.getAction().equals("android.intent.action.PHONE_STATE")) {
                    if ((bundle = intent.getExtras()) != null) {
                        state = bundle.getString(TelephonyManager.EXTRA_STATE);
    }
}

Here I create a new call receiver so I can listen to call action

if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                    String number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
                    if(number!=null) {
                        if(!phone.contains(number))
                        phone.add(number);
                    }
                    wasRinging = true;
                    callDirection = 2;
                }

Then I have a list of numbers that I added the number to it to know how many numbers was in the call

if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
                    createAndRecord();
                }

Then I start the call record when the call is answered

Now if a new call received when the previous call is in progress the app should do the following:

  • Add the calling number to phones list ✔
  • if the call was not answered (declined or missed) the app should remove the phone from the list but what I found is the status is OFFHOOK if the new call is answered or declined or missed how can I detect if it's missed
0

There are 0 best solutions below