IndexOutOfBound Exception throwing Android

后端 未结 2 760
逝去的感伤
逝去的感伤 2021-01-28 09:52

i have make one android application in that data is coming from server so it\'s time consuming process so i have created one progress dialog box..

below is my code

2条回答
  •  别那么骄傲
    2021-01-28 10:41

    In the cases where you get the error onResume() gets called again, starting a new AsyncTask. Now you have multiple AsyncTask simultanously accessing and altering the size of nearDeals.results (you call remove on it). When one asyncTask removes an item from the list, the second asyncTask may run into the ArrayIndexOutOfBounds since the list size has changed.

    EDIT: It's actually not the removal of an item, but that you set a new instance of the list in googlePlaces.search and this list may have a different size than the one used by the old asynctask.

    Solution: call cancel on your running async tasks in onPause (or in onResume before starting the new task)

提交回复
热议问题