Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activity has leaked IntentReceiver android.widget.ViewFlipper

Tags:

android

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.

like image 625
Code Poet Avatar asked Jan 02 '12 12:01

Code Poet


1 Answers

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

like image 94
Code Poet Avatar answered Oct 24 '22 09:10

Code Poet