How to check if the dialed number is busy or is not answered?

24,823

You cannot determine whether an outgoing call on the mobile network was answered, because this information isn't provided to the handset by the mobile network, and even if it was, Android does not provide a way to receive it.

While it's possible to determine whether an outgoing Internet (SIP) call was answered, Android doesn't currently (as of Jelly Bean) provide a way of doing this that I can find from a quick look at the source code.

Share:
24,823
Zardaloop
Author by

Zardaloop

Updated on June 19, 2020

Comments

  • Zardaloop
    Zardaloop almost 4 years

    I have used the following code to dial a number:

    DataBaseHelper db;
    db=new DataBaseHelper(PanicService.this);
    try {
    
        db.createDataBase();
    
        } catch (IOException ioe) {
    
        throw new Error("Unable to create database");
    
        }
    
    Map<String, String > map= db.TelephoneList();
    String[] numbers = new String[]{"number1","number2","number3","number4","number5"};
    
    
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse("tel:"+map.get(numbers[0])));
    callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(callIntent);
    

    which is working fine. Now I need to know if the dialled number is busy or is unanswered, and it it is dial the next number in the list. I am just wondering if there is anyway to detect the state of the call?

    I have checked this URL http://developer.android.com/reference/android/telephony/TelephonyManager.html but I can't find anything around that concept apart from CALL_STATE_OFFHOOK which is not really what I want.

  • Michael Hampton
    Michael Hampton almost 12 years
    The phone hangs up when the user presses the End Call button, or the mobile network disconnects the call. You can receive those events.
  • Zardaloop
    Zardaloop almost 12 years
    Oh I see , that will be DATA_DISCONNECTED,fromt he telephony manager, right ?
  • Michael Hampton
    Michael Hampton almost 12 years
    DATA_DISCONNECTED refers to the phone's mobile data (3G, 4G etc.) connection, not the phone call. When the phone hangs up, ACTION_PHONE_STATE_CHANGED will be broadcast with an EXTRA_STATE set to EXTRA_STATE_IDLE (which corresponds to CALL_STATE_IDLE).
  • Abdul Aziz
    Abdul Aziz almost 6 years
    Phone receives lot of network related info like call was answered or not, how many times bell rang etc, but as of now there is no open android API that we can use