android - Schedule Executor's Schedule Method is Executing Only Once -


i trying implement sample schedule want toast displayed every 10 seconds.but schedule method running once.is there solution. here code

public class mainactivity extends appcompatactivity {

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      scheduledexecutorservice scheduledexecutorservice= executors.newscheduledthreadpool(1);     scheduledexecutorservice.schedule(new runnable() {         @override         public void run() {             runonuithread(new runnable() {                 @override                 public void run() {                     toast.maketext(getapplicationcontext(), "hello schedule", toast.length_long).show();                 }             });         }     },     10, timeunit.seconds);  } 

}

read documentation on difference between scheduledexecutorservice#schedule() , scheduledexecutorservice#scheduleat*


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -