Threading in Android to process long running processes

后端 未结 1 1826
孤城傲影
孤城傲影 2021-01-20 03:04

Ok, here is my problem. I want to learn AsyncTask, Threading and Handler to process long running tasks. I used Android Cook Book and New Boston Android tutorial, but I can\'

1条回答
  •  有刺的猬
    2021-01-20 03:17

    Why are you creating a new Thread just to wait 2 seconds to call AsyncTask? I would suggest you to remove that Thread, normally call the AsyncTask and inside it place Thread.sleep(....).

    Something like:

    protected void onPreExecute(String f){
         Thread.sleep(2000);
         //example of setting up something
         f = "whatever";
    }
    

    PS: in order to run a Thread, you need to call thread.start. ;)

    0 讨论(0)
提交回复
热议问题