I load the data from the server in batches. New portions are loaded when scrolling the screen. I load using AsyncTask.
The list has simple elements and group elements. If you click on the group, another activity opens, in which only the group elements are loaded.
The problem is this: I go to the group, go out, I go to another group and the error flies:

java.lang.IllegalStateException: the notification has been changed. It is not modified.

I still can not understand how to fix it .. Here is my AsyncTask

class MyTask extends AsyncTask<String, Integer, Void> { protected ProgressBar proBar; protected TextView proText; @Override protected void onPreExecute() { proBar = (ProgressBar) findViewById(R.id.progress_bar); proBar.setVisibility(View.VISIBLE); proText = (TextView) findViewById(R.id.progress_bar_text); proText.setText("loading..."); proText.setVisibility(View.VISIBLE); } @Override protected Void doInBackground(String... params) { // TODO ссылка ReadStringJson rsj = new ReadStringJson(SERVER_URL_1 + SERVER_PATH_2 + SERVER_PATH_3 + GROUP + "&from=" + (from + 1) + "&number=" + number + SERVER_PATH_4 + FILTER); try { parsingData(rsj.readFromServer()); } catch (IOException ex) { Log.e("IOException: ", ex.toString()); ex.printStackTrace(); } catch (JSONException ex) { Log.e("JSONException: ", ex.toString()); ex.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); adapter.addEnginesNames(names); adapter.addEnginesDescriptions(descriptions); adapter.addEnginesLogoUrl(logoUrl); adapter.addIsGroup(isGroup); adapter.notifyDataSetChanged(); } } 
  • parsingData does not modify the adapter? You need to find all places possible adapter modifications and check that you call notifyDataSetChanged. - KoVadim 5:09
  • @KoVadim, no, parsingData does not do anything with the adapter, json parsing just goes there. The only place where the adapter is updated is onPostExecute - Stas0n
  • @KoVadim, do you have any idea what the joint is? - Stas0n
  • There is. The problem does not accidentally play, if during the operation of asynctask rotate the screen? - KoVadim
  • one
    I missed the question "The problem is as follows: I go to the group, I go out, I go to another group and the error takes off:" This is the problem. As with the turn, and at the entrance-exit, the activation is re-created. Remains the old AsyncTask. He is trying to update the ListView, which is already gone. - KoVadim pm

1 answer 1

The Russian language says that the adapter should be updated in the UI stream!

Which means that updating the adapter should be removed from under AsyncTask

  • onPostExecute is executed in the UI thread. - KoVadim
  • @Barmaley, how then does the adapter need to be updated, if not on onPostExecute? - Stas0n