private void save_logs_to_server(Double lat, Double lon) {
String vehicle_no = getSharedData("vehicle_no");
if(timer()-my_timer>update_interval){
DownloadWebPageTask task = new DownloadWebPageTask();
task.execute(new String[] { server+"/save_logs.php?vehicleno="+vehicle_no+"&lat="+lat+"&lon="+lon+"&speed="+speed});
my_timer=timer();
}
else if(timer()-my_timer<0){
my_timer=0;
}
}
This is the piece of code that im using to repeatedly execute asynctask after according to the value of the variable update_interval
The timer () method i had written returns the clock in seconds
My doubt is : Do I need to use Timer class for the above purpose? Which one has less CPU overhead; the Timer or above strategy?
Any suggestions will be appreciated