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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -