How to get outgoing call connected state

倾然丶 夕夏残阳落幕 提交于 2019-12-07 13:15:41

问题


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.


回答1:


I never tried with outgoing calls but with incoming calls you can play with the THREE STATES YOU'VE mentioned.

  1. STATE_RINGING: call is ringing.
  2. STATE_OFF_HOOK: if the previous state was RINGING, the call got connected.
  3. 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.




回答2:


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.



来源:https://stackoverflow.com/questions/11031590/how-to-get-outgoing-call-connected-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!