Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my android app detect a dropped call?

Tags:

android

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

like image 971
Sam Avatar asked Jun 30 '10 22:06

Sam


People also ask

What does it mean when it says call was dropped?

What is a dropped call? A dropped call happens when your phone gets disconnected somehow from the cellular network. Usually, this happens because of poor cell signal wherever you are that causes the call to drop.

How does calling app work?

A calling app allows users to receive or place audio or video calls on their device. Calling apps use their own user interface for the calls instead of using the default Phone app interface, as shown in the following screenshot. The Android framework includes the android.


2 Answers

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.

like image 133
Andy Hall Avatar answered Nov 08 '22 17:11

Andy Hall


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

like image 39
Trevor Johns Avatar answered Nov 08 '22 19:11

Trevor Johns