I want to trigger AsynTask inside the Timer thread, I am getting this following error.
java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
Is it possible or not ??? Here is my code
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);