Code example for ScheduledExecutorService

Methods: scheduleWithFixedDelay

0
		private final SyncTask task;
 
		private ExecuterWithNotification(SyncTask task, long fixedDelaySeconds) {
			this.task = task;
			this.executer = Executors.newSingleThreadScheduledExecutor();
			this.executer.scheduleWithFixedDelay(task, 1L, fixedDelaySeconds, TimeUnit.SECONDS);
		} 
 
		public void dispose() { 
			try { 
				executer.shutdownNow();
			} catch (Exception e) {
				Log.e(ExecuterWithNotification.class.getSimpleName(), "Can't dispose executer", e);
			} finally { 
				task.dispose();
			} 
		} 
	} 
	 
	@Override protected void onChildTitleChanged (Activity childActivity, CharSequence title){
		this.setTitle(title);