Detect if an outgoing call has been answered
Asked Answered
K

4

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?

Kacikacie answered 12/2, 2010 at 8:30 Comment(8)
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 disconnectedEarthshaking
Currently it's not possible to detect when exactly they have picked up; the Caller app uses an internal intent for that.Kacikacie
yeah this is what I too concluded today :-|, anyways thanksEarthshaking
if u dont mind please provide info ,how do u use internal intent to get the info about outgoing call received.Winkle
Look at these threads. They disrcribe how to detect when the user answers the phone. #7930250 #9514144Dunite
It's funny that duplicate questions get answers but this one has none.Stepdaughter
did you find any way to achieve it? maybe by polling or using reflection on CallManager : grepcode.com/file_/repository.grepcode.com/java/ext/… ?Donofrio
Possible duplicate of How to detect when phone is answered or rejectedJeep
E
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.

Elodiaelodie answered 30/4, 2012 at 9:7 Comment(0)
E
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.

Elman answered 12/2, 2010 at 8:48 Comment(1)
Yes, however, I do need to capture this event!Kacikacie
H
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)

Hornstone answered 16/2, 2014 at 9:21 Comment(1)
not true onCallStateChanged does exactly this.Salaidh
O
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...

Odo answered 6/11, 2013 at 17:25 Comment(3)
If we set targetSdkVersion of our app to < 4.2. Can we then read the system logs using logcat?Inconsecutive
i'm afraid not. because it's the Phone app's logs that are sand boxed. It doesn't matter which sdk your app is using.Virescent
Not true there is a onCallStateChanged event that can be usedSalaidh

© 2022 - 2024 — McMap. All rights reserved.