title: Android - Service - On Start Command Called only once
body: <p>In my activity oncreate method, i have called a service using OnStartCommand(). My requirement is when the user is on the same Activity (when the Activity is visible), a set of code should run repeatedly. (Example .. I should make a web service call and get the response and do some action based on it after regular intervals).</p>
  
  <p>I have put this set of code in this method.</p>
  
  <pre><code>@Override
       public int onStartCommand(Intent i, int flags , int startId){
  
          // Code to be repeated
  
  return Service.START_STICKY;
  }
  </code></pre>
  
  <p>But, this is getting executed only once. How to make it run repeatedly from the time the user came to this page till he leaves this page ??</p>