Retrieve call information

  1. Import the required class.
  2. Invoke PhoneCall.getElapsedTime() to retrieve the length of time of the current call. Invoke PhoneCall.getStatus() to retrieve the connection status for the call. Invoke PhoneCall.getDisplayPhoneNumber() to retrieve the phone number of the call. In the following code sample, a status message displays on the screen when the phone call has lasted more than 120 seconds.
    int threshold = 120; 
    int elapsedTime = call.getElapsedTime();
    int status = call.getStatus();
    if ((status == PhoneCall.STATUS_CONNECTED 
       || status == PhoneCall.STATUS_CONNECTING) 
       && call.isOutGoing() && elapsedTime > threshold)
       String phoneNumber = call.getDisplayPhoneNumber();"Your call to " + call.getDisplayPhoneNumber() + " has lasted more than " + 
          (String)threshold + ".");

Was this information helpful? Send us your comments.