54

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mobilekid
  • 1,629
  • 5
  • 19
  • 27
  • did yo u find the solution to your problem ? i am also looking for the same solution. I want to know if the other end user has picked up the call or he has disconnected – Shaista Naaz Apr 27 '11 at 12:42
  • Currently it's not possible to detect when exactly they have picked up; the Caller app uses an internal intent for that. – mobilekid Apr 28 '11 at 14:31
  • yeah this is what I too concluded today :-|, anyways thanks – Shaista Naaz Apr 28 '11 at 14:36
  • if u dont mind please provide info ,how do u use internal intent to get the info about outgoing call received. – kiran Apr 16 '12 at 04:26
  • 2
    Look at these threads. They disrcribe how to detect when the user answers the phone. http://stackoverflow.com/questions/7929750/how-to-know-the-moment-when-the-called-person-picks-up-his-phone http://stackoverflow.com/questions/9513644/how-can-i-detect-when-a-call-is-answered – Mikael Svensson Aug 21 '12 at 12:18
  • It's funny that duplicate questions get answers but this one has none. – o_O Aug 21 '12 at 19:23
  • did you find any way to achieve it? maybe by polling or using reflection on CallManager : http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/2.3.3_r1/com/android/internal/telephony/CallManager.java/?v=source ? – android developer Oct 01 '13 at 13:57
  • Possible duplicate of [How to detect when phone is answered or rejected](https://stackoverflow.com/questions/9684866/how-to-detect-when-phone-is-answered-or-rejected) – kaustav07 Jul 11 '17 at 21:48

4 Answers4

7

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.

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
rbd
  • 187
  • 2
  • 10
3

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.

pgsandstrom
  • 14,361
  • 13
  • 70
  • 104
1

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)

kkreddy
  • 297
  • 3
  • 2
0

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...

neteinstein
  • 17,529
  • 11
  • 93
  • 123