title: Android keep CountDownTimer running when app is in the background
body: <p>In my app, I implement <code>CountDownTimer</code> in my listview as following:</p>
  
  <p><code>OrdersCountDownTimer.java</code></p>
  
  <pre><code>public class OrdersCountDownTimer extends CountDownTimer {
  
      private OrdersAdapter adapter;
  
      public OrdersCountDownTimer(long millisInFuture, long countDownInterval, OrdersAdapter adapter) {
          super(millisInFuture, countDownInterval);
          this.adapter = adapter;
      }
  
      @Override
      public void onTick(long millisUntilFinished) {}
  
      @Override
      public void onFinish() {
          adapter.decTime();
          adapter.notifyDataSetChanged();
          this.start();
      }
  }
  </code></pre>
  
  <p><code>OrdersActivity.java</code></p>
  
  <p><code>timer = new OrdersCountDownTimer(ONE_SECOND, ONE_SECOND, adapter);</code></p>
  
  <p>So, I'm decrementing the value in my <code>Order</code> object upon every tick my timer finishes.</p>
  
  <p>The problem is that this is running in my main thread, which means when my app goes to the background or the screen is locked, the <code>timer</code> is paused as well.</p>
  
  <p>I would like to keep the <code>timer</code> running at all times. Is there a way to do this?</p>