title: How to stop binding service when app is killed from recent apps in Android 10
body: <p>I have a service which I start in <code>onCreate</code> method with </p>
  
  <pre><code>val service = Intent(this,Service::class.java)
  startService(service)
  bindService(service, ServiceConnection, Context.BIND_AUTO_CREATE)
  </code></pre>
  
  <p>and I unbind from it in <code>onStop</code>. Service is responsible for updating current location. In it, on <code>onCreate</code> method, I start location updates with looper from newly created ThreadHandler(created in service).</p>
  
  <pre><code>val newThread = HandlerThread("LocationUpdatesThread")
  newThread.start()
  locationManager.requestLocationUpdates(
      LocationManager.GPS_PROVIDER,
      1000,
      1f,
      locationListener, newThread.looper)
  </code></pre>
  
  <p>Problem I have is, that this service is not stopped or at least some background process is left hanging when application is killed from recent apps. To this conclusion I got because I'm using Pusher in main activity to listen for online status of users, but when i kill an app, user is not unsubscribed from channel - meaning app is not closed properly. Also, if I don't start service at all, everything works fine, so that's why I think the problem is with the service. Twist is that this occurs <strong>ONLY in API 29</strong> ( Android 10). On APIs below everything works fine - meaning service is being kill as it should. I have set in android manifest service tag <code>stopwithtask="true"</code> that handles killing of service. Does anyone have some idea why is this happening or what am I missing?</p>