Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid-The content of the adapter has changed but ListView did not receive a notification.content adapter is not modified from a background thread
    text
    copied!<p>I am getting this Exception when I am Modifying a listview. </p> <blockquote> <p>The content of the adapter has changed but ListView did not receive a notification. Content adapter is not modified from a background thread.</p> </blockquote> <p>But I am not modifying anything on background thread and this also I am not getting frequently. Only some times when I got multiple pns, if the device goes to sleep mode, after that when it is unlocked, the app clicking on listview is causing the crash.</p> <p>Here is the Code which I have written for showing messages in <code>ListView</code>.</p> <pre><code>private class GetMessagesAsyncronousTask extends AsyncTask&lt;Void, Void, Void&gt; { private ProgressDialog myAsyncTask = null; @Override protected void onPreExecute() { myAsyncTask = new ProgressDialog(MessageActivity.this); myAsyncTask.setMessage(getString(R.string.msg_refresh_label)); myAsyncTask.setIndeterminate(true); myAsyncTask.setCancelable(false); if (myAsyncTask != null &amp;&amp; !myAsyncTask.isShowing()) { try { myAsyncTask.show(); } catch (WindowManager.BadTokenException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } super.onPreExecute(); } @Override protected Void doInBackground(Void... params) { // Here i am calling the web services and inserting the data in DB. } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (myAsyncTask != null &amp;&amp; myAsyncTask.isShowing()) { try { myAsyncTask.dismiss(); myAsyncTask = null; } catch (WindowManager.BadTokenException e1) { e1.printStackTrace(); } catch (Exception e2) { e2.printStackTrace(); } } // this method is for updating the messages Count in spinner and list view rows when push notification came. resetAdapter(); } } } </code></pre> <p>In <code>ResetAdapter</code>, based on spinner selection I am showing corresponding messages in <code>listview</code>.</p> <pre><code>DropdownAdapter dropDownAdapter = new DropdownAdapter( MessageActivity.this, R.layout.row_dropdown_action, listNavigationArray); dropDownAdapter .setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowTitleEnabled(false); ActionBar.OnNavigationListener navigationListener = new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int itemPosition, long itemId) { navigateToFolder(itemPosition); return false; } }; getActionBar().setListNavigationCallbacks(dropDownAdapter, navigationListener); } </code></pre> <p>//Navigate Folder Method.</p> <pre><code> private void navigateToFolder(int itemPosition) { if (itemPosition == 2) { listView.setVisibility(View.GONE); archiveListView.setVisibility(View.VISIBLE); recipientListView.setVisibility(View.GONE); final List&lt;MessageBean&gt; readMessageList = messageManager .getMessageList("read", user.getSponsorId(), user.getUserId()); final CheckBoxAdapter checkBoxAdapter = new CheckBoxAdapter( MessageActivity.this, readMessageList); archiveListView.setAdapter(checkBoxAdapter ); } else if (itemPosition == 3) { recipientListView.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); archiveListView.setVisibility(View.GONE); adapter = new AddressAdapter(MessageActivity.this, R.layout.row_address, matchedRecipients); recipientListView.setAdapter(adapter); } else if (itemPosition == 0) { listView.setVisibility(View.VISIBLE); archiveListView.setVisibility(View.GONE); recipientListView.setVisibility(View.GONE); messageList = messageManager.getUnreadMessageList("unread", user.getSponsorId(), user.getUserId()); inboxAdapter = new MessageListAdapter(MessageActivity.this, R.layout.custome_row_message, messageList); refreshYourAdapter(messageList); listView.setAdapter(inboxAdapter); } else if (itemPosition == 1) { listView.setVisibility(View.VISIBLE); archiveListView.setVisibility(View.GONE); recipientListView.setVisibility(View.GONE); inboxAdapter = new MessageListAdapter(MessageActivity.this, R.layout.custome_row_message, pendingMessageList); refreshYourAdapter(pendingMessageList); listView.setAdapter(inboxAdapter); } } private void refreshYourAdapter(final List&lt;MessageBean&gt; items) { runOnUiThread(new Runnable() { public void run() { if (inboxAdapter != null) { inboxAdapter.refreshAdapter(items); } } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload