title: Android: keep Service running when app is killed
body: <p>I want to keep a <code>IntentService</code> running in background even when the app is killed. And by "killed" I mean <em>press home-button for a long time</em> -> <em>see all running apps</em> -> <em>swipe my app aside</em> -> <em>app killed</em> OR <em>press back-button for a long time</em> -> <em>app killed</em></p>
  
  <p>My code goes as follows. In my MainActivity:</p>
  
  <pre><code>Intent intent = new Intent(this, MyService.class);
  this.startService(intent);
  </code></pre>
  
  <p>In my MyService:</p>
  
  <pre><code>public class MyService extends IntentService {
  
  @Override
  protected void onHandleIntent(Intent intent) {
      System.out.println("MyService started");
      run();
  }
  
  private void run() {
      while (true){
          System.out.println("MyService still running");
          doSomething();
          waitSomeTime();
      }
  }
  
  }
  </code></pre>
  
  <p>I see that the service is running when the app is <em>open</em>. It's still running when I <em>minimize the app</em> via home-button. It's still running when I <em>close the app</em> via back-button. But it will stop if I kill it as mentioned above. How do I solve this?</p>