Recursively call handlerMessage from a started service?
<p>I need to do some recursive tasks, say do something after every five seconds. How to achieve that? I will need to do the recursive task in the background, so I think I can go with a <code>Started Service</code>.</p>

<p>PS. What I am actually trying to do is: taking picture using camera after every five seconds, from a background service.</p>

<p>I found following code in the developer-guide. The method below resides in a custom class which extends <code>Handler</code> class:</p>

<pre><code>@Override
      public void handleMessage(Message msg) {
      // Do Something
      // HOW CAN i MAKE A RECURSIVE CALL (TO SOMEHOW CALL THIS FUNCTION) AFTER 5 SECONDS?
      // Stop the service using the startId
      stopSelf(msg.arg1);
      }
  }
</code></pre>

<p>Can I call something like <code>Thread.sleep(5000)</code> just before <code>stopSelf()</code>? (Not making sense to me...)</p>

<p>Or can I call something like <code>this.sendMessageDelayed(msgOb, 5000);</code> ?</p>

<p>Thanks.</p>
