title: Run a service in background continuously
body: <p>Run a service in background continuously. For example, a service has to be kicked off which will display a toast message 20 seconds once even if the app is closed.</p>
  
  <pre><code>public class AppService extends IntentService {
  
      public int onStartCommand(Intent intent, int flags, int startId) {
          return START_STICKY;
      }
  
      public AppService() {
          super("AppService");
      }
  
      @Override
      protected void onHandleIntent(Intent workIntent) {
          Toast.makeText(getApplicationContext(), "hai", Toast.LENGTH_SHORT).show();
          SystemClock.sleep(20000);
      }
  }
  </code></pre>