从共享菜单泄露IntentReceiver [英] Leaked IntentReceiver from sharing menu

查看:149
本文介绍了从共享菜单泄露IntentReceiver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从一个按钮,点击特定活动打开发送菜单:

I'm opening the send menu from a button click in a particular activity:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, "meh");
try {
    startActivity(Intent.createChooser(i, "pfft"));
} ...

当打回来关闭它工作正常,但是,logcat的说:

Works fine, but when hitting "Back" to close it, logcat says

活动com.android.internal.app.ChooserActivity渗漏,最初这里注册IntentReceiver com.android.internal.app.ResolverActivity$1@405ab288。你缺少unregisterReceiver()的调用?

没有什么事情发生 - 应用程序将继续没有问题运行

Nothing else happens - the app continues to run without a problem.

搜索说,显然高于code已经注册了BroadcaseReceiver,它需要被注销(通过unregisterReceiver),可能是onResume(或在onPause)期间。用于注销接收签名说,单一的参数应该是一个BroadcastReceiver实例(有意义)。

Searching says that apparently the above code has registered a BroadcaseReceiver and it needs to be unregistered (via unregisterReceiver), probably during onResume (or onPause). The signature for unregister receiver says the single argument should be a BroadcastReceiver instance (makes sense).

我的问题是 - 哪里是参照广播接收器? AFAICT用来打开菜单的方法不返回一个BroadcastReceiver - ?我怎么找到并引用一个合适的注销它

My question is - where is the reference to the BroadcastReceiver? AFAICT the methods used to open the menu don't return a BroadcastReceiver - how do I find and reference the appropriate one to unregister it?

TYIA

(要注意的是,我debuging上三星Galaxy SII和<一个href=\"http://stackoverflow.com/questions/7526136/sprint-samsung-galaxy-s2-activity-has-leaked-intentreceiver-are-you-missing\">this螺纹表明它可能是一个特定于设备的错误?)

(should note that I'm debuging on a Samsung Galaxy SII, and this thread indicates it might be a device-specific bug?)

推荐答案

显然,这是Android的某些设备的缺陷。请参见本报告: HTTP://$c$c.google .COM / p /安卓/问题/细节?ID = 29399 。它看起来当您使用选配喜欢它只是一个问题,只有一个选项可供选择。

Apparently this is a bug in Android with certain devices. See this report: http://code.google.com/p/android/issues/detail?id=29399. It looks like it's only a problem when you use a chooser and there is only one option to choose from.

如果你调用Intent.createChooser()时,如果有唯一可能的选择泄漏一个BroadcastReceiver。

If you call Intent.createChooser(), it will leak a BroadcastReceiver if there's only possible option.

,这个问题似乎是ResolverActivity正在注册中的onCreate()接收器,但是然后调用完成()如果只有一个选项。这将导致code跳过的onStop(),这是在接收器的注册。

Based on the current source, the problem appears to be that ResolverActivity is registering the receiver in onCreate(), but then calling finish() if there's only one option. This causes the code to skip onStop(), which is where the receiver is unregistered.

这篇关于从共享菜单泄露IntentReceiver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆