我需要认识到广播事件时如何识别是否收到传出呼叫的电话状态或不
走出去通话开始,
的走出去,在接电话接收端和
的走出去电话挂断
我能够获得来电通话事件,但不能拨打电话事件。
这是我的代码,请找出我的问题并给出解决方案。
由于提前
@Override
public void onReceive(Context context, Intent intent) {
// We listen to two intents. The new outgoing call only tells us of an
// outgoing call. We use it to get the number.
if (intent.getAction()
.equals("android.intent.action.NEW_OUTGOING_CALL")) {
savedNumber = intent.getExtras()
.getString("android.intent.extra.PHONE_NUMBER");
} else {
String stateStr = intent.getExtras()
.getString(TelephonyManager.EXTRA_STATE);
String number = intent.getExtras()
.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
int state = 0;
if (stateStr.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
state = TelephonyManager.CALL_STATE_IDLE;
} else if (stateStr.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
state = TelephonyManager.CALL_STATE_OFFHOOK;
} else if (stateStr.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
state = TelephonyManager.CALL_STATE_RINGING;
}
onCallStateChanged(context, state, number);
}
}