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
Post a Comment