Array adapter and listview issues after launching Intent Service

青春壹個敷衍的年華 提交于 2019-12-11 20:27:09

问题


I have a list view being populated by my array adapter. Now everything works fine until i click on a row which launches an async task.

My async task is supposed to download some image urls and launch an intent service in it's onPostExecute to download the images and store them on the SDcard.

All this works fine but once i hit back and relaunch the fragment mid the network operations, my listview is empty and remains empty until the intent service is done. What could be the problem here? I have an AsyncTask handling the downloads in the intent service so why does the service "block" the main thread?


回答1:


After reading around i finally found out what i was doing wrong, mainly due to this question here and here. onHandleIntent runs on a worker thread so there really was no need for me to create an Async task in the intent service in the first place. So i replaced my Async task in the intent service with a method and called that method in onHandleIntent and that solved my problem.



来源:https://stackoverflow.com/questions/28705584/array-adapter-and-listview-issues-after-launching-intent-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!