我正试图在接听电话时收到该事件。我搜索并发现应该使用CALL_STATE_OFFHOOK。但是这不起作用。拨打号码后立即调用此状态。这是我的代码:
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (TelephonyManager.CALL_STATE_RINGING == state) {
// phone ringing
// But this gets called as soon as number is dialled.
endCall();
}
if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
// active
phoneCalling = true;
new CountDownTimer(MyApplication.GetData().getDuration()*1000, 1000) {
public void onTick(long millisUntilFinished) {
}
public void onFinish() {
endCall();
}
}.start();
}
// When the call ends launch the main activity again
if (TelephonyManager.CALL_STATE_IDLE == state) {
MyApplication.GetData().setIsReturnedFromCall(false);
if (phoneCalling) {
phoneCalling = false;
}
}
答案 0 :(得分:0)
我发现这是由于我的call recorder
应用uninstalling
和reinstalling
没什么不同。我必须先进入设置,然后进入应用程序,单击该应用程序并存储,然后依次输入clear data
。这解决了问题。