当行已经拨出电话时已经连接的Andr​​oid检测拨出、电话、oid、Andr

2023-09-06 06:32:28 作者:风软一江水

只是一个快速的背景,我上有根的Nexus one运行CM7。 我想检测时呼出实际上连接:已停止振铃和您呼叫的人已回答。翻翻论坛,这似乎是一个艰难的,也许没有答案的问题。我真的AP preciate任何洞察到这一点。

Just a quick background I'm Running CM7 on a rooted Nexus one. I am trying to detect when an outgoing call is actually connected: has stopped ringing and the person you are calling has answered. Looking through the forums this seems to be a tough and perhaps unanswered question. I'd really appreciate any insight into this.

在我寻找最好的,我能找到的是: Android :如何获得一个状态,即呼出已回答了? @PattabiRaman说:而不是检测呼出呼叫连接的状态,很容易得到最后的已拨电话的时间。 他的意思是一个人应该得到最后拨打的通话持续时间与通话过程中?而当时间越过0,那么你知道吗?

In my searching the best I could find was in: Android : How to get a state that the outgoing call has been answered? @PattabiRaman said: "instead of detecting the outgoing call connection state, it is easy to get the duration of the last dialed call." Does he mean that one should get the duration of the last dialed call as the call is in progress? And when that duration goes over 0 then you know?

推荐答案

com.android.internal.telephony.CallManager 有关于当调用实际上是信息回答。它有一个公共静态方法的getInstance()返回的CallManager的实例,以及一个公共的方法 getActiveFgCallState()返回当前呼叫状态为 Call.State 枚举。 因此,从理论上讲是这样的可能工作:

The class com.android.internal.telephony.CallManager should have information about when the call actually is answered. It has a public static method getInstance() which returns the CallManager instance, and a public method getActiveFgCallState() which returns the current call state as a Call.State enum. So in theory something like this might work:

Method getFgState = null;
Object cm = null;

try {
  Class cmDesc = Class.forName("com.android.internal.telephony.CallManager");
  Method getCM = cmDesc.getMethod("getInstance");
  getFgState = cmDesc.getMethod("getActiveFgCallState");
  cm = getCM.invoke(null);
} catch (Exception e) {
  e.printStackTrace();
}

,然后反复轮询状态:

And then repeatedly poll the state:

Object state = getFgState.invoke(cm);
if (state.toString().equals("IDLE")) {
  ...
} else if (state.toString().equals("ACTIVE")) {
  // If the previous state wasn't "ACTIVE" then the
  // call has been established.
}

我还没有证实这确实有效。而且,即使它你必须记住,该API可能会改变,因为这是不是该应用程序的开发人员都应该依靠。

I haven't verified that this actually works. And even if it does you'll have to keep in mind that the API could change, since this isn't something that app developers are supposed to rely on.

 
精彩推荐
图片推荐