我需要認識到廣播事件時如何識別是否收到傳出呼叫的電話狀態或不
走出去通話開始,
的走出去,在接電話接收端和
的走出去電話掛斷
我能夠獲得來電通話事件,但不能撥打電話事件。
這是我的代碼,請找出我的問題並給出解決方案。
由於提前
@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);
}
}