AsyncTask ; doInbackground() not called after calling method onPreExecute()

前端 未结 4 1206
星月不相逢
星月不相逢 2021-02-01 03:34

I did added async library at my project and checked already, I don\'t know why code flow doesn\'t go in to asynctask

Code

public void doMysql()
{
    Log         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 04:17

    Quoting Android Documentation for Async Task

    When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.

    If you truly want parallel execution, you can invoke executeOnExecutor(java.util.concurrent.Executor, Object[]) with THREAD_POOL_EXECUTOR.

    Use this snippet for triggering AsyncTask:

    if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
       asyncTaskInstance.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    else
       pdfPageChanger.execute(params);
    

提交回复
热议问题