BroadcastReceiver 允许调用继续,但阻止其他接收者处理它?
BroadcastReceiver which allows call to proceed, but prevents other receivers from processing it?
我有一个 BroadcastReceiver 应用程序,它处理 NEW_OUTGOING_CALL
意图。我的 phone 上还有其他应用程序注册为这些意图的接收者,但我的应用程序注册了更高优先级的意图过滤器,所以我的 BroadcastReceiver 可以首先看到意图。
我希望能够以编程方式阻止 NEW_OUTGOING_CALL
的任何其他已注册 BroadcastReceiver 处理这些意图,但我希望允许 phone 调用继续进行。这可能吗?
我不认为你真的可以做你想做的事。此操作的 documentation 非常清楚地描述了系统期望如何处理此广播:
For consistency, any receiver whose purpose is to prohibit phone calls should have a priority of 0, to ensure it will see the final phone number to be dialed. Any receiver whose purpose is to rewrite phone numbers to be called should have a positive priority. Negative priorities are reserved for the system for this broadcast; using them may cause problems.
如果你想先看到号码,你可以这样做(优先级更高),但是你必须忍受其他接收者在你看到它之后看到它。或者,您可以最后看到该号码(通过将您的优先级降低到 0
),但是您必须忍受其他接收者在您之前看到该号码。
请注意,另一个人建议中止广播。这不仅没有意义,因为系统需要广播的结果,而且在文档中也明确说明 not 中止此广播。
Any BroadcastReceiver receiving this Intent must not abort the broadcast.
我有一个 BroadcastReceiver 应用程序,它处理 NEW_OUTGOING_CALL
意图。我的 phone 上还有其他应用程序注册为这些意图的接收者,但我的应用程序注册了更高优先级的意图过滤器,所以我的 BroadcastReceiver 可以首先看到意图。
我希望能够以编程方式阻止 NEW_OUTGOING_CALL
的任何其他已注册 BroadcastReceiver 处理这些意图,但我希望允许 phone 调用继续进行。这可能吗?
我不认为你真的可以做你想做的事。此操作的 documentation 非常清楚地描述了系统期望如何处理此广播:
For consistency, any receiver whose purpose is to prohibit phone calls should have a priority of 0, to ensure it will see the final phone number to be dialed. Any receiver whose purpose is to rewrite phone numbers to be called should have a positive priority. Negative priorities are reserved for the system for this broadcast; using them may cause problems.
如果你想先看到号码,你可以这样做(优先级更高),但是你必须忍受其他接收者在你看到它之后看到它。或者,您可以最后看到该号码(通过将您的优先级降低到 0
),但是您必须忍受其他接收者在您之前看到该号码。
请注意,另一个人建议中止广播。这不仅没有意义,因为系统需要广播的结果,而且在文档中也明确说明 not 中止此广播。
Any BroadcastReceiver receiving this Intent must not abort the broadcast.