3

I can use this code to make outgoing call:

Intent dial = new Intent(Intent.ACTION_CALL); 
dial.setData(Uri.parse("tel:5556") ); 
context.startActivity(dial);

But how to detect whether the call is picked up or the call is refused? I tried PhoneStateListener, but it is not working.

Pattabi Raman
  • 5,814
  • 10
  • 39
  • 60

3 Answers3

1

Unfortunately, Android gives no mean to know when an outgoing call has been answered.

PhoneStateListener works fine but the 3 states notified by onCallStateChanged are not enough. An additional state like CALL_STATE_CONNECTED would be welcome.

There is an open issue requesting this feature but it didn't get much attention so far: https://code.google.com/p/android/issues/detail?id=14266

Some people (like me) falls back using logcat and tries to infer if an outgoing call has been answered but this is far from an ideal solution.

  • +1 for the fact that call state ACTIVE is actually being logged by OS to the general device's logcat (at least on my Samsung S5). This saved my day!!! :) – Kozuch Feb 21 '17 at 13:31
0

I am also searching for an answer to the same problem, apparently no straight forward method is present to do this. But, I think we can combine a Call Log content observer with PhoneStateListener to get the call duration. We could set a flag in the shared prefs when an outgoing call is started, if anything changes in call log and our shared prefs flag is true we could get the call duration from the call log to see if the call was ever connected :)

Naeem A. Malik
  • 995
  • 4
  • 19
-1

You can Check these Duplicate questions:

Community
  • 1
  • 1
Adel Boutros
  • 10,205
  • 7
  • 55
  • 89
  • 1
    hi, i was asking about the outgoing call, the links you provided is used for the incoming calls. – Pattabi Raman Aug 13 '12 at 04:00
  • @PattabiRaman Not really, Did you really read the 2nd link? I quote: _When the call is hanged up(due to success/failure), my application should get to know this along with the reason of hangup_ – Adel Boutros Aug 13 '12 at 07:54
  • Those links provide no information as to whether a call got connected. All it provides is detection for idle and hanging up. – Johann Mar 05 '13 at 10:09
  • @AndroidDev Thank you for your inexplicable down vote. On a side note, if the question is askable, why has there been no answers since more than a year. Next time, instead of downvote, try to answer. Thanks – Adel Boutros Mar 05 '13 at 10:33
  • @AndroidDev Did you even check the links before you comment? – Adel Boutros Mar 05 '13 at 10:34
  • Yes I did. Did you even bother to try the code? Clearly you didn't, otherwise you would have known it won't work. You got down voted for posting code that clearly does not work for the problem stated. Next time, try testing code before you post it or links to someone else's. – Johann Mar 05 '13 at 14:26
  • @AndroidDev Again, what is your proposed solution? That's what matter not the [chit-chat](http://en.wiktionary.org/wiki/chit-chat).. – Adel Boutros Mar 05 '13 at 17:18