Search code examples
androidasynchronousandroid-asynctask

Activity's UI freezes on AsyncTask's onPostExecute?


I used AsyncTask to request for a large chunk of data. When received, the data is processed inside the onPostExecute method. It may take a while to process the data.

Based from my understanding, AsyncTask is asynchronous and is independent from the UI.

  • Why does my Activity freezes onPostExecute?
  • Is it normal for an Activity to freeze if processing inside the onPostExecute method is too long?
  • How do I make it such that my Activity won't freeze onPostExecute?

Solution

    1. You should do all your datasource operations like(database , network ,parsing the response.etc) in doInBackground method.
    2. If you want update any ui updation in async task the use onProgressUpdate
    3. I think you are performing any parsing operations in onPostExecute. try getting filtered or parsed data (lighter data) in onPostExecute.