new a AsyncTask cause 'Can't create handler inside thread that has not called Looper.prepare()'

来源:互联网 发布:金蝶进销存软件多少钱 编辑:程序博客网 时间:2024/05/17 07:05

Can't create handler inside thread that has not called Looper.prepare()


There are a few threading rules that must be followed for this class to work properly:

  • The AsyncTask class must be loaded on the UI thread. This is done automatically as of JELLY_BEAN.
  • The task instance must be created on the UI thread.
  • execute(Params...) must be invoked on the UI thread.
  • Do not call onPreExecute()onPostExecute(Result)doInBackground(Params...)onProgressUpdate(Progress...) manually.
  • The task can be executed only once (an exception will be thrown if a second execution is attempted.)

0 0