0

我只是想doInBackground()AsyncTask. 出于这个原因,我尝试在里面使用线程doInBackground()

protected String doInBackground(String... input) {
    // TODO Auto-generated method stub
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(3000);
            }catch(InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    };
    timer.start();
    return null;
}

我猜中的线程是作为单独执行的??因为onPostExecute()在忽略我提出的延迟之后立即调用。

有人可以提出一些建议,以便我可以延迟拨打onPostExecute().

4

1 回答 1

2

使用Thread.sleep(3000)代替您正在使用doInBackground的。Thread这将使AsyncTask睡眠 3 秒。

于 2013-11-11T10:28:53.713 回答