How to differentiate between a missed call and an refuse to answer? - android

I am designing an application in which I need to differentiate between a call rejected by the receiver (by pressing the dialing button) with the one not answered and is disconnected by the one who is dialing. is there anything that makes a differentiation since both of these come under the missed call category in Android?

You are lacking some details; please advise.
Are you referring to the Call Log provider android.provider.CallLog.Calls? There are only 3 call types defined. Can you provide the data of all the fields for such a Call Log entry?
The only other way (we know of) to tell is to watch the Phone State (via IntentReceiver) and track the transitions yourself. Most likely, a transition of Ringing to Idle would indicate the call was refused instead of answered, in which case it would transition Ringing to Offhook.

Related

Detecting if call is on hold in Android

I am working on an App that should detect when Phone Call is placed on hold, all I can find in Android Telephony documentation is 3 states, that is CALL_STATE_RINGING when Phone is ringing, CALL_STATE_OFFHOOK When call is in progress or on Hold or CALL_STATE_IDLE when no call activity exists, but I would like to know, has anyone found out a way around to detect exactly when call is on Hold? I need to do some action only when call is on hold.
Take a look at this answer https://stackoverflow.com/a/29490832/3836513 . Using PreciseCallState you can read when call is put on hold.
This is possible in Android 5.0 using the The PreciseCallState, You can read call state such as idle,busy and ringing.GithubCode PreciseCallStateDetail

Detect Call On Hold

I wanted to know if there is any definitive way to know if the call is put on hold by the receiver on the receiver side only.
Now I checked the Telephony documentation, and this shows that there are three states for a call :
CALL_STATE_IDLE: When no call activity is there
CALL_STATE_RINGING: When a new call is ringing and waiting to be taken up.
CALL_STATE_OFFHOOK: At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
Here lies the problem, OFFHOOK takes the active and hold state as one. There seems to be no way to distinguish between them.
But an interesting observation I made was that dialler recieves a notification when the call is retrieved from hold, that means there exists some way to know the difference. Hence, I would be obliged if you assist me in finding that way.
It looks like the current Telephony APIs doen't let you read the precise call state.
In this commit, however
https://github.com/android/platform_frameworks_base/commit/c5ac15a3e11c03951e269b243674858411204b67
You can see a proposal for a precise call state monitoring.
https://android-review.googlesource.com/#/c/60660/
Here you can see that at Feb 13 5:26 AM this "Change has been successfully merged into the git repository."
This means that sooner or later we'll see it in a future Android release.

How do I know who ended the call in Android - User or Remote User?

I want to specifically know who ended the call. I have setup a broadcast receiver for
"android.intent.action.PHONE_STATE"
When I detect a transition from Off hook to idle, I know the call has ended. But how do I know who ended the call?
Thanks a ton!
I'm afraid there's presently no way to determine if the user pressed "end call" or if the other end (or ends, in a group call) terminated. The only workaround I can suggest is monitoring the other states to observe if the phone state ringing was encountered. In such a case, you could assume the user is making the phone call as opposed to receiving it.
Bear in mind that there are other problems related to PHONE_STATE, such as handling multiple calls simultaneously.
In retrospect, I'm not entirely sure what you mean with "who". As for other apps ending the call: there is no official API to end phone calls; only through reflection can an app invoke the TelephonyService's endCall() function. Here, too, it is not possible to determine if the call was terminated through user interaction or not.

Out going call answered state in Android 2.2+

In my application I initiated an outgoing call and I am using PhoneStateListener to know about call state.
Whenever I start making call the phone state is TelephonyManager.CALL_STATE_OFFHOOK. When call recipient answered the call, I am not getting any change in phone's state.
I tried many but failed to get this answered state. Somebody told use bluetooth's HFP (Hands Free Profile) to get call answered state. But I didn't get any information about HFP from android developers website.
If anybody faced same problem and got the solution, please give your valuable suggestions.
The CALL_STATE_OFFHOOK doesn't change when the call is answered by the recepient:
Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
The state shouldn't change as long as the phone is in call, whether it's answered or not.
This question had been asked many items, and so far none of the those I found have been solved: Detect if an outgoing call has been answered, Android : How to get a state that the outgoing call has been answered?, Android : How to get a state that the outgoing call has been answered? (There are many others). The solutions provided there rely on the CALL_STATE_OFFHOOK state to change when the call is answered, which doesn't happen.
Seems like there is no public API which can be used to get the outgoing call state. The best workaround I see is what Vivek Khandelwal suggested., it's not so long to code nor has heavy performance overheads. Unless adding too many permissions (Now you need to add READ_CALL_LOGS) is a problem, use it.
I too had the same problem. This may not be the answer for your question. I am just sharing what I did.
I had an activity which opens the Contact and can make a call. What I wanted is, to known whether the call was successful (i.e recipient answered to the call).
There was no solution i found at that time with PhoneStateListener.
So as a work around, what I did is checked the Call Logs if it has a outgoing call to the phone numbers of that contact after starting the Contact Activity.
See if his help.
you want something specific to bluetooth? Otherwise I can provide sources

How to get outgoing call connected state

In my application development, I need to do vibration when outgoing call connected, but I can not get the call answered state. I have read some topic about this question, such as:
Outgoing call status
But actually, these questions not be answered correctly. Use BroadcastReceiver can only receive idle, offhook, ringing states, but no active state.
The active state defined in Call.java in internal framework, I have no idea to get this state. I did use reflection method, almost same as https://stackoverflow.com/questions/5652660/accessing-callmanager-in-android, But failed also.
I never tried with outgoing calls but with incoming calls you can play with the THREE STATES YOU'VE mentioned.
STATE_RINGING: call is ringing.
STATE_OFF_HOOK: if the previous state was RINGING, the call got connected.
STATE_IDLE: if prev state was RINGING: Call rejected. If prev state was OFF_HOOK call connected and then disconnected (i.e. completed).
I have code for this implementation for incoming calls. Since you mentioned you can access these states in outgoing calls as well, I think this should work for outgoing calls as well. If you want I can post my code.
After wondering and spending a lot of time on the net I found a way to achieve this...
Just query the call history of the device based on time of your last dialed call, fetch the duration of that call, if found greater than 0 that means your call was accepted and it works perfect.
if someone unable to get it, lets me know I will elaborate it with code.

Categories

Resources