How to display contacts in Android using AsyncTask?

前端 未结 4 823
庸人自扰
庸人自扰 2021-01-07 14:43

I\'m trying to list all the contacts in mobile. So far everything was working fine, but when I thought of running my code in AsyncTask I\'m getting nothing on s

4条回答
  •  轮回少年
    2021-01-07 15:17

    You are trying to call setAdapter in doInBackground which is not running on UI thread. You must pass the result of contact loading from doInBackground(..) to onPostExcecute(..) and there you can create a an adapter and set it in the list view.

提交回复
热议问题