在BroadcastReceiver中使用abortBroadcast()

时间:2015-06-22 21:49:16

标签: java android

当TelephonyManager等于CALL_STATE_RINGING时,如何在BroadcastReceiver中使用abortBroadcast()函数?

1 个答案:

答案 0 :(得分:0)

让您的课程延长extends PhoneStateListener

覆盖onCallStageChanged()

@Override
public void onCallStateChanged(int state, String incomingNumber) {
    if (state == TelephonyManager.CALL_STATE_RINGING) {
         // phone is ringing, do your thing with abortBroadcast()
    }
}

并按照您认为合适的方式实施中止

如果您获得BroadcastReceiver trying to return result during a non-ordered broadcast,请移除对setResultCode();

的来电