title: Creating a periodical service in Android
body: <p>I'm trying to create a periodical service where I can validate certain values stored on my mobile with the data I have on my API Server. If a user's password gets changed or if the user gets deleted the API Server should send a response back so the mobile app knows the user should be signed out. The request/response is not the problem. Just having issues getting the service periodically. </p>
  
  <p>MyService.class:</p>
  
  <pre><code>public class MyService extends IntentService {
  
      private static final String TAG = "MyService";
  
  
      public MyService() {
          super("MyService");
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          // Normally we would do some work here, like download a file.
          // For our sample, we just sleep for 5 seconds.
          try {
              Thread.sleep(5000);
              Log.d(TAG,"loop service");
          } catch (InterruptedException e) {
              // Restore interrupt status.
              Thread.currentThread().interrupt();
          }
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
          Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();
          return super.onStartCommand(intent, flags, startId);
      }
  }
  </code></pre>
  
  <p>Inside the onCreate of another random class:</p>
  
  <pre><code>Context mContext = getApplicationContext();
  Intent i= new Intent(mContext, MyService.class);
  i.putExtra("KEY1", "Value to be used by the service");
  mContext.startService(i);
  </code></pre>
  
  <p>The service does start (it shows me the Log.d), how do I continue from here to get it restarted or to make it start after certain time?</p>