我已经注册了incomingCall广播接收器,它工作得很好,但是当呼叫建立(或拒绝)时,我需要接收器。我真正需要的是当用户按"接听"或"拒绝"呼叫时通知我的东西。
你可以重写BroadcastReceiver的onReceive方法,如下所示
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
//Phone is ringing
} else if (state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
//Call received
} else if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
//Call Dropped or rejected
}
}