title: Pausing / Resuming Handler post delayed
body: <p>I am trying to start an activity after a delay of 2 seconds . The code -</p>
  
  <pre><code>runnable = new Runnable() {
          @Override
          public void run() {
              final Intent i = new Intent(PreviewCoordinatesActivity.this,
                      StylePreviewActivity.class);
              i.putExtra(AppConstants.IMAGEPATH, sImagePath);
              moveNextToAndFinish(i);
          }
      };
      handler.postDelayed(runnable, DELAY);
  </code></pre>
  
  <p>I want to pause the operation when the activity is paused and resume the operation once the activity comes back to foreground .</p>
  
  <p>At present i am just removing the callback when the activity is paused -</p>
  
  <pre><code>@Override
  protected void onPause() {
      super.onPause();
      if (handler != null) {
          if (runnable != null)
              handler.removeCallbacks(runnable);
      }
  
  }
  </code></pre>