我需要的,如果不是我如何检查它的任何方法来检查,如果我注册的接收器仍然是注册?
I need to check if my registered receiver is still registered if not how do i check it any methods?
我不知道该API提供了直接的API,如果你考虑的这个线程:
I am not sure the API provides directly an API, if you consider this thread:
我想知道同样的事情。
在我来说,我有一个的BroadcastReceiver
执行调用
上下文#unregisterReceiver(BroadcastReceiver的)
传递自己作为处理其接收的意图后,ARG。
有一个小的机会,接收器的的onReceive(上下文,意图)
方法被调用
不止一次,因为它是注册多个 IntentFilters
,创造潜在的抛出:IllegalArgumentException
从上下文#unregisterReceiver(BroadcastReceiver的)。
I was wondering the same thing.
In my case I have a BroadcastReceiver
implementation that calls
Context#unregisterReceiver(BroadcastReceiver)
passing itself as the arg after handling the Intent that it receives.
There is a small chance that the receiver's onReceive(Context, Intent)
method is called
more than once, since it is registered with multiple IntentFilters
, creating the potential for an IllegalArgumentException
being thrown from Context#unregisterReceiver(BroadcastReceiver)
.
在我来说,我可以存储私人同步成员呼吁上下文#unregisterReceiver(BroadcastReceiver的)
前检查,但它会
如果API提供的检查方法,更清洁。
In my case I can store a private synchronized member to check before calling Context#unregisterReceiver(BroadcastReceiver)
, but it would be
much cleaner if the API provided a check method.