The timer task doesn’t wait for the scheduled delayed time.
I want to delay the network check by 10 seconds,but it performs the action within few seconds without waiting.Any help would be appreciated.
int i = 0;
public void timertask()
{
while(i < 5){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
if(isNetworkConnected()) // Some method to check net connection
{
download(); //Method to download
}
}
}, 10000);
System.out.println("i = "+i);
i++;
}
}
try this one.