I'm searching some pages from facebook and then downloading their pictures. i want to view them immediately in my list and update the adapter everytime i download a new picture. i'm using the same method in one other activity and it works, but here i'm using a dialog and it freeze my UI till everything is finished, even if i'm doing it in background. why?
private synchronized void getUserLikesImages() {AsyncTask<Void, Void, Bitmap> task = new AsyncTask<Void, Void, Bitmap>() {
@Override
public Bitmap doInBackground(Void... params) {
for(...){
//download one picture...
FacebookeventsActivity.this.runOnUiThread(new Runnable() {
public void run() {
pagesILikeArrayAdapter.notifyDataSetChanged();
}
});
}
};
task.execute();
}
it works, but the UI is frozen till the end of the operations... i think it might be because my list is in a dialog and i'm running it on UIThread, but i don't know how to fix it.