我想觸發定時器線程內的AsynTask,我收到以下錯誤。定時器和異步在一起
java.lang.ExceptionInInitializerError 產生的原因:了java.lang.RuntimeException:無法內螺紋創建處理程序尚未調用Looper.prepare()
是否有可能或不??? 這裏是我的代碼
networkTimer = new Timer();
networkTimer.schedule(new TimerTask() {
int counter = 1;
@Override
public void run() {
// TODO Auto-generated method stub
if(isNetworkAvailable()){
Log.d("Hey I got the Network","!!");
new GmailAsync().execute("");
networkTimer.cancel();
}else{
Log.d("Attempt","No:"+counter);
counter++;
if(counter == 6){
Log.d("Attempt","Finished");
networkTimer.cancel();
}
}
}
},0, 5000);
的http://計算器。 com/questions/10496744/start-asynctask-in-timertask – jnr
我從她的http://stackoverflow.com/questions/10496744/start-asynctask-in-timertask工作很好:) –