Activity has leaked IntentReceiver android.widget.ViewFlipper

匿名 (未验证) 提交于 2019-12-03 00:50:01

问题:

I'm adding a ViewFlipper inflated from a layout resource into a ListView as a Footer. Here's my flipper layout (Details omitted for brevity):

<?xml version="1.0" encoding="utf-8"?> <ViewFlipper ...>     <Button         />     <LinearLayout          ... >         <ProgressBar             ... />         <TextView             ... />     </LinearLayout> </ViewFlipper> 

I add it to my ListView using :

mListView.addFooterView(mLoadMoreFlipper); 

When my activity is destroyed I see the following message, followed by a call stack, in LogCat:

 Activity com.gk.ItemListActivity has leaked IntentReceiver android.widget.ViewFlipper$1@44c84ab0   that was originally registered here. Are you missing a call to unregisterReceiver()? 

I did some digging around and found out the message is related to not unregistering receivers, except I haven't registered any. Oddly this message only appears if the footer ViewFlipper has been removed from the ListView before destruction (by using the back button). I detach the footer when I no longer need it by using:

mListView.removeFooterView(mLoadMoreFlipper); 

I have tried using a WeakReference to the ViewFlipper but that doesn't help. I also tried setting the mLoadMoreFlipper reference to null but that doesn't help either.

Has anyone encountered this problem before? This seems to be related to my activity holding a reference to the ViewFlipper after it's been detached from the ListView but I do not know how to explicitly destroy the ViewFlipper.

回答1:

See View Flipper Throws Exception in ViewFlipper.onDetachedFromWindow. Apparently there is a bug in ViewFlipper. The contains the workaround.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!