android - Call an async task repeatedly (lets say every 10 seconds) using tasktimer -


my requirement call async task repeatedly every 10 seconds webservice fetch data update (updating of map , image) accordingly.

i searched throughout , found out 1 can use tasktimer this. problem facing parameter passed asynctask. not able pass parameter tasktimer.

i found out separate class should created extends timer task. have no idea how done according need.

please kind enough me. code passing parameter async task given below.

new asyncloadgpsdetails().execute(username); 

i want repeatedly perform async task. please me, don't know how create class extends tasktimer i'm newbie this.

thanks & regards in advance

you can use either use scheduleatfixedrate or schedulewithfixeddelay...

scheduleatfixedrate

  // task specified time run repeat   repeattask.scheduleatfixedrate(new timertask() {   @override   public void run() {               // here               // task run every 10 sec repeat         }   }, 0, 10); 

schedulewithfixedelay

scheduler.schedulewithfixeddelay(new timertask() {   @override   public void run() {               // here               // task run every 10 sec delay         }   },, 0, 10, timeunit.seconds); 

find difference between them here


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -