BroadcastReceiver卸载问题

0-27 00:38:44.953: E/ActivityThread(10801): Activity com.freshen.test.TestLocationActivity has leaked IntentReceiver com.freshen.test.TestLocationActivity$1@40522d28 that was originally registered here. Are you missing a call to unregisterReceiver()?
10-27 00:38:44.953: E/ActivityThread(10801): android.app.IntentReceiverLeaked: Activity com.freshen.test.TestLocationActivity has leaked IntentReceiver com.freshen.test.TestLocationActivity$1@40522d28 that was originally registered here. Are you missing a call to unregisterReceiver()?
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:799)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:575)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:852)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ContextImpl.registerReceiver(ContextImpl.java:839)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ContextImpl.registerReceiver(ContextImpl.java:833)
10-27 00:38:44.953: E/ActivityThread(10801): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
10-27 00:38:44.953: E/ActivityThread(10801): at com.freshen.test.TestLocationActivity.onCreate(TestLocationActivity.java:43)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
10-27 00:38:44.953: E/ActivityThread(10801): at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 00:38:44.953: E/ActivityThread(10801): at android.os.Looper.loop(Looper.java:143)
10-27 00:38:44.953: E/ActivityThread(10801): at android.app.ActivityThread.main(ActivityThread.java:4277)
10-27 00:38:44.953: E/ActivityThread(10801): at java.lang.reflect.Method.invokeNative(Native Method)
10-27 00:38:44.953: E/ActivityThread(10801): at java.lang.reflect.Method.invoke(Method.java:507)
10-27 00:38:44.953: E/ActivityThread(10801): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-27 00:38:44.953: E/ActivityThread(10801): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)

10-27 00:38:44.953: E/ActivityThread(10801): at dalvik.system.NativeStart.main(Native Method)

=============================================================================================================

public abstract Intent registerReceiver (BroadcastReceiver receiver, IntentFilter filter)
Since:  API Level 1

Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread.

The system may broadcast Intents that are "sticky" -- these stay around after the broadcast as finished, to be sent to any later registrations. If your IntentFilter matches one of these sticky Intents, that Intent will be returned by this function and sent to your receiver as if it had just been broadcast.

There may be multiple sticky Intents that match filter, in which case each of these will be sent to receiver. In this case, only one of these can be returned directly by the function; which of these that is returned is arbitrarily decided by the system.

If you know the Intent your are registering for is sticky, you can supply null for your receiver. In this case, no receiver is registered -- the function simply returns the sticky Intent that matches filter. In the case of multiple matches, the same rules as described above apply.

See BroadcastReceiver for more information on Intent broadcasts.

As of ICE_CREAM_SANDWICH, receivers registered with this method will correctly respect the setPackage(String) specified for an Intent being broadcast. Prior to that, it would be ignored and delivered to all matching registered receivers. Be careful if using this for security.

Note: this method cannot be called from a BroadcastReceiver component; that is, from a BroadcastReceiver that is declared in an application's manifest. It is okay, however, to call this method from another BroadcastReceiver that has itself been registered at run time with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of such a registered BroadcastReceiver is tied to the object that registered it.

Parameters
receiver The BroadcastReceiver to handle the broadcast.
filter Selects the Intent broadcasts to be received.
Returns
  • The first sticky intent found that matches filter, or null if there are none.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值