Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在广播接收器中使用abortBroadcast()_Java_Android - Fatal编程技术网

Java 在广播接收器中使用abortBroadcast()

Java 在广播接收器中使用abortBroadcast(),java,android,Java,Android,当TelephonyManager等于CALL\u STATE\u RINGING时,如何在BroadcastReceiver中使用abortBroadcast()函数?让您的类扩展扩展PhoneStateListener 重写onCallStageChanged() 并执行您认为合适的中止 如果在非顺序广播过程中,BroadcastReceiver试图返回结果,请删除对setResultCode()的调用 @Override public void onCallStateChanged(in

当TelephonyManager等于
CALL\u STATE\u RINGING
时,如何在BroadcastReceiver中使用abortBroadcast()函数?

让您的类扩展
扩展PhoneStateListener

重写onCallStageChanged()

并执行您认为合适的中止


如果在非顺序广播过程中,
BroadcastReceiver试图返回结果,请删除对
setResultCode()的调用

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