title: Android Background Service is restarting when application is killed
body: <p>I am developing an application in which a background service is created to collect sensor data. I am starting the service from my activity:</p>
  
  <pre><code>startService(new Intent(this, MyService.class));
  </code></pre>
  
  <p>I created the service so if the application is destroyed, the background service still continues to collect data. I tried this, and it worked to a certain extent. My problem is that when I kill the application, the service seems to restart because the <code>onCreate()</code> service and the <code>onStart()</code> methods are invoked. Is there any way with which the service isn't restarted please?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>As suggested in an answer below, I added the following method in the service but no luck.</p>
  
  <pre><code>@Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      return START_NOT_STICKY;
  }
  </code></pre>