Android Open Source - CakeUI Cake Periodic Service






From Project

Back to project page CakeUI.

License

The source code is released under:

GNU General Public License

If you think the Android project CakeUI listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cakeui.generic.service;
//from w  w  w  . j  ava  2 s. com

/**
 * Class that implements a generic service that is executed periodically.
 * Initially, is set to execute the task once per minute, but the time interval can be changed.
 * 
 * @author Sarah Caixeta
 * @email caixeta.sarah@gmail.com
 *
 */
public class CakePeriodicService extends CakeService implements Runnable{

  private static final long ONE_MINUTE = 60000;
  
  private Thread syncThread;
  private long interval = ONE_MINUTE;
  
  @Override
  public void onCreate() {
    super.onCreate();
    startThread();
  }
  
  public void startThread() {
    if (syncThread == null){
      syncThread = new Thread(this);
      syncThread.start();
    }
  }
  
  @Override
  public void run() {
    while (true) {

      try {
        performTask();
        
        Thread.sleep(interval);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    
  }
  
  public void setTimeInterval(long timeMillis){
    this.interval = timeMillis;
  }
  
  public long getTimeInterval(){
    return this.interval;
  }
    
}




Java Source Code List

com.cakeui.application.CakeApplication.java
com.cakeui.generic.activity.CakeActivity.java
com.cakeui.generic.adapter.CakeExpandableListViewAdapter.java
com.cakeui.generic.adapter.CakeGridViewAdapter.java
com.cakeui.generic.adapter.CakeListViewAdapter.java
com.cakeui.generic.dialog.CakeDialog.java
com.cakeui.generic.fragment.CakeFragment.java
com.cakeui.generic.service.CakePeriodicService.java
com.cakeui.generic.service.CakeService.java
com.cakeui.utils.CakeAsyncTask.java
com.cakeui.utils.CakeBroadcastReceiver.java
com.cakeui.utils.CakeComparator.java
com.cakeui.utils.CakeDataEncapsulation.java
com.cakeui.utils.CakeMap.java
com.cakeui.utils.enums.AsyncTaskType.java
com.cakeui.utils.enums.DialogType.java
com.cakeui.utils.enums.PagesOpen.java