I have a ListActivity that starts a service. In this service, I started a thread that does some database query of up to 800 contacts, this seems to be slowing down or even hanging the UI sometimes. Should I开发者_JAVA技巧 be using AsyncTask instead? What is the proper way to handle this?
Normally services are running on UI-Thread. But you had mentioned that you are using thread in services it mean your work is doing in background so there is no any possibility to block UI-Thread.
I think you had write a some code out of thread for update UI and that may be blocking your UI.
You can use AsyncTask
instead of starting service and updating using thread because asynctask is doing same thing as background thread can do.
Try incremental load of the contacts for your list. Querying so much data would of course slow your thread down.
精彩评论