title: Android Service shutting down when function works longer than (about) 15 seconds
body: <p>I have a service which works with LongPoll and when I receive my data everything is OK, but when I don't receive data, rather I receive empty result (long polling max time == 25 sec) my service sometimes turning off manually (and I don't see it in list of services).</p>
  
  <p><strong>So, how to keep this service (..always..) running?</strong></p>
  
  <p>Recursive function, which works with long polling and at first calls in service's <code>onCreate()</code> (structure):</p>
  
  <pre><code>//"u" is "new utils()".
  public class myservice extends Service {
    public static boolean started=false;
    @Override
    public void onCreate() {
      super.onCreate();
      Toast.makeText(this, "created qweqwe", Toast.LENGTH_LONG).show();
      longpoll();
      this.started=true;
    }
    @Override
    public void onDestroy() {
      super.onDestroy();
      this.started=false;
    }
    private String url = "http://example.com/lp.php";
    private void longpoll() {
      try {
        String resp = u.getData(url); //max time of working u.getData(lpurl) - 25s.
        if (resp.length()&gt;0) doSmthWithData(resp); //It works fine
      } catch(Exception e) {}
      longpoll();
    }
  }
  </code></pre>