Detect if an outgoing call has been answered

AndroidAndroid IntentTelephony

Android Problem Overview


Once ACTION_NEW_OUTGOING_CALL has been broadcasted, I need to capture the following event of the other party answer. Could you advice on how to achieve that please? I know it is possible as the Android dialer app changes the green Android icon to the person's photo exactly when they pick up.

UPDATED: I've had a look at the source of the app on Android handling the outgoing calls. I noticed the following method in ContactsUtils:

/**
 * Kick off an intent to initiate a call.
 */

 public static void initiateCall(Context context, CharSequence
 phoneNumber) {
     Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
             Uri.fromParts("tel", phoneNumber.toString(), null));
     context.startActivity(intent); }

I guess my answer is in the activity listening for Intent.ACTION_CALL_PRIVILEGED. So to rephrase my question: Does anyone know which activity handles Intent.ACTION_CALL_PRIVILEGED?

Android Solutions


Solution 1 - Android

I don't think there's such API and also there's no API for sending DTMFs due to the same reason that you can't tell when the call is being connected.

Solution 2 - Android

It does not necessarily needs to be possible to capture this as an outside app. The green android icon is a part of the application that controls the call, so it does not need a broadcast to change the icon.

Solution 3 - Android

As far as android's telephony manager is concerned u cannot detect programmatically whether the call has been answered or not. This is to say that u do not have the option to know when the user picked the phone at other end. Android has got 3 states of telephony manager and none of them are capable of detecting whether the call was actually answerd or not(IN CASE OF OUTGOING CALLS)

Solution 4 - Android

The only way you may be able to do this is by parsing the Logcat logs, no PhoneStateListener event is available for that.

Some are asking for it here: https://code.google.com/p/android/issues/detail?id=14266

Anyway, in versions above Android 4.2 as Logcat is "sandboxed" it may be impossible...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmobilekidView Question on Stackoverflow
Solution 1 - AndroidrbdView Answer on Stackoverflow
Solution 2 - AndroidpgsandstromView Answer on Stackoverflow
Solution 3 - AndroidkkreddyView Answer on Stackoverflow
Solution 4 - AndroidneteinsteinView Answer on Stackoverflow