11

I am writing an app that is meant to be run during a call. After the user makes a call, and starts my app, I want my app to be able to know if the call is dropped from bad connection. Is this possible? Thanks

Sam
  • 143
  • 1
  • 8

2 Answers2

5

Doesn't CALL_STATE_OFFHOOK -> CALL_STATE_IDLE also indicate a normally terminated call?

Regardless, you can simply check the call state using the onCallStateChanged callback method of the PhoneStateListener class. This will be called whenever the state changes and you can switch the provided status to find which state it is in.

Andy Hall
  • 51
  • 1
1

The Android TelephonyManager class provides the getCallState() method, which will tell you the status of the current call. You'll be looking for a transition from CALL_STATE_OFFHOOK to CALL_STATE_IDLE.

Unfortunately, I don't see any methods in there to register a callback, so you may have to resort to polling.

http://developer.android.com/reference/android/telephony/TelephonyManager.html

Trevor Johns
  • 15,682
  • 3
  • 55
  • 54
  • 2
    How would the state transition for a regular hang-up be different than offhook -> idle? – Sam Jul 09 '10 at 16:40
  • Ah, I see what you're asking now. Unfortunately, from what I can see, I don't think there's any way to differentiate between a dropped call, the user hanging up, or the remote party hanging up. – Trevor Johns Jul 12 '10 at 21:35
  • how to know that the person who is calling cancelled the call himself? do we have any flow to that? – Syed Raza Mehdi Jun 06 '14 at 07:57
  • @TrevorJohns But when call is dropped by network it show message **Call Drop** when call ended by user it shows message **call ended** right ? What deferential these two ? – Kathi Apr 04 '16 at 11:26