title: Android - Background service stops when its invoker activity is destroyed
body: <p>I have an always-running background service, started on my MainActivity. The problem is, <strong>when MainActivity is destroyed, my service gets restarted</strong>. This scenario is the only one in which the service stops, so the "always-running" thing is working well.</p>
  
  <p><strong>I would like to know why this is happening, and what I could do to prevent it.</strong></p>
  
  <p>My service is not bound to my activity, because I don't need it.</p>
  
  <p><strong>The service:</strong></p>
  
  <pre><code>public class LocationService extends Service implements GoogleApiClient.ConnectionCallbacks,
      GoogleApiClient.OnConnectionFailedListener, LocationListener {
  
      ...
      public LocationService() {
  
      }
  
      @Override
      public void onCreate() {
  
          // Some initialization logic here
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
  
          return START_STICKY;
      }
  
      ...
  }
  </code></pre>
  
  <p><strong>MainActivity:</strong></p>
  
  <pre><code>public class MainActivity extends BaseActivity {
  
      ...
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Start location service in background
          Intent intent = new Intent(this, LocationService.class);
          startService(intent);
      }
  }
  </code></pre>
  
  <p>Thanks in advance! :D</p>