Compdigitec Labs

« | Home | »

Fixing IllegalStateException: The content of the adapter has changed but ListView did not receive a notification

By admin | November 16, 2013

Recently while working with a custom BaseAdapter in ListView, I came across this error:

E/InputEventReceiver(30380): Exception dispatching input event.
E/MessageQueue-JNI(30380): Exception in MessageQueue callback: handleReceiveCallback
E/MessageQueue-JNI(30380): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131230721, class android.widget.ListView) with Adapter(class com.compdigitec.libvlcandroidsample.DirectoryAdapter)]
E/MessageQueue-JNI(30380): 	at android.widget.ListView.layoutChildren(ListView.java:1544)
E/MessageQueue-JNI(30380): 	at android.widget.AbsListView.onTouchEvent(AbsListView.java:3403)
E/MessageQueue-JNI(30380): 	at android.view.View.dispatchTouchEvent(View.java:7239)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2168)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1903)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
E/MessageQueue-JNI(30380): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
E/MessageQueue-JNI(30380): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)
E/MessageQueue-JNI(30380): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)
E/MessageQueue-JNI(30380): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2410)
E/MessageQueue-JNI(30380): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901)
E/MessageQueue-JNI(30380): 	at android.view.View.dispatchPointerEvent(View.java:7419)
E/MessageQueue-JNI(30380): 	at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)
E/MessageQueue-JNI(30380): 	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165)
E/MessageQueue-JNI(30380): 	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)
E/MessageQueue-JNI(30380): 	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)
E/MessageQueue-JNI(30380): 	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363)
E/MessageQueue-JNI(30380): 	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
E/MessageQueue-JNI(30380): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MessageQueue-JNI(30380): 	at android.os.MessageQueue.next(MessageQueue.java:125)
E/MessageQueue-JNI(30380): 	at android.os.Looper.loop(Looper.java:124)
E/MessageQueue-JNI(30380): 	at android.app.ActivityThread.main(ActivityThread.java:5191)
E/MessageQueue-JNI(30380): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/MessageQueue-JNI(30380): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/MessageQueue-JNI(30380): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
E/MessageQueue-JNI(30380): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
E/MessageQueue-JNI(30380): 	at dalvik.system.NativeStart.main(Native Method)

this.notifyDataSetChanged() was already being called, so that couldn’t have been the problem.

The solution?
If registerDataSetObserver() and unregisterDataSetObserver() are going to be overridden, ensure that the superclass’ methods are being called too. If you forget to call them, then when Android registers the ListView dataset observer, nothing is going to happen.

    @Override
    public void registerDataSetObserver(DataSetObserver arg0) {
        // ...stuff
        super.registerDataSetObserver(arg0);
    }

    @Override
    public void unregisterDataSetObserver(DataSetObserver arg0) {
        // ...stuff
        super.unregisterDataSetObserver(arg0);
    }

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Mobile | 11 Comments »

11 Responses to “Fixing IllegalStateException: The content of the adapter has changed but ListView did not receive a notification”

  1. รับทำบัญชี ภูเก็ต Says:
    November 10th, 2024 at 19:52

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  2. Herbalife account Says:
    November 13th, 2024 at 02:22

    … [Trackback]

    […] Info on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  3. สมัครเว็บบอล auto Says:
    November 15th, 2024 at 22:30

    … [Trackback]

    […] Find More here on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  4. KU WEB หวย รวมครบทุกการเดิมพันไว้ในที่เดียว Says:
    November 20th, 2024 at 19:34

    … [Trackback]

    […] Read More on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  5. ซื้อหวยออนไลน์ เว็บไหนดี จ่ายจริง ไม่มีเลขอั้น Says:
    November 24th, 2024 at 18:50

    … [Trackback]

    […] Find More on on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  6. ทัวร์ธุรกิจจีน Says:
    November 27th, 2024 at 02:38

    … [Trackback]

    […] There you will find 53881 more Information to that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  7. กระเบื้องทางเท้า Says:
    November 28th, 2024 at 13:09

    … [Trackback]

    […] Information on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  8. pgslot Says:
    December 5th, 2024 at 22:20

    … [Trackback]

    […] Find More on to that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  9. Destination Wedding in France Says:
    December 5th, 2024 at 23:57

    … [Trackback]

    […] There you will find 15846 more Information on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  10. torch disposable vape Says:
    December 17th, 2024 at 16:27

    … [Trackback]

    […] Read More on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

  11. แพคเกจทัวร์ Says:
    December 20th, 2024 at 22:25

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2013/11/16/fixing-illegalstateexception-the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notification/ […]

Comments