title: Foreground service onTaskRemoved Failure sending broadcast Intent android.os.DeadObjectException
body: <p>I'm developing <a href="https://github.com/mauron85/cordova-plugin-mauron85-background-geolocation-phonegapbuild" rel="nofollow">https://github.com/mauron85/cordova-plugin-mauron85-background-geolocation-phonegapbuild</a></p>
  
  <p>Basically it's cordova plugin which is using LocationManager to send locations to webview.</p>
  
  <p>The core is implemented as android.app.Service which is started in foreground to reduce chances being killed by os.</p>
  
  <p>Also service has own process (android:process=":remote").
  So service will survice main activity (thread) kill or app closed by user. And even if killed it will restart automatically by setting flag START_REDELIVER_INTENT in onStartCommand.</p>
  
  <p>My problem is, that after app is closed (swiped away from task lisk), service crash after couple of seconds. And in the log I see:</p>
  
  <pre><code>W/BroadcastQueue(  562): Failure sending broadcast Intent { act=com.tenforwardconsulting.cordova.bgloc.STATIONARY_REGION_ACTION flg=0x10 (has extras) }
  W/BroadcastQueue(  562): android.os.DeadObjectException
  W/BroadcastQueue(  562):    at android.os.BinderProxy.transactNative(Native Method)
  W/BroadcastQueue(  562):    at android.os.BinderProxy.transact(Binder.java:496)
  W/BroadcastQueue(  562):    at android.app.ApplicationThreadProxy.scheduleRegisteredReceiver(ApplicationThreadNative.java:1093)
  W/BroadcastQueue(  562):    at com.android.server.am.BroadcastQueue.performReceiveLocked(BroadcastQueue.java:431)
  W/BroadcastQueue(  562):    at com.android.server.am.BroadcastQueue.deliverToRegisteredReceiverLocked(BroadcastQueue.java:521)
  W/BroadcastQueue(  562):    at com.android.server.am.BroadcastQueue.processNextBroadcast(BroadcastQueue.java:729)
  W/BroadcastQueue(  562):    at com.android.server.am.BroadcastQueue$BroadcastHandler.handleMessage(BroadcastQueue.java:149)
  W/BroadcastQueue(  562):    at android.os.Handler.dispatchMessage(Handler.java:102)
  W/BroadcastQueue(  562):    at android.os.Looper.loop(Looper.java:135)
  W/BroadcastQueue(  562):    at android.os.HandlerThread.run(HandlerThread.java:61)
  W/BroadcastQueue(  562):    at com.android.server.ServiceThread.run(ServiceThread.java:46)
  W/ActivityManager(  562): Scheduling restart of crashed service com.xpressgo.courier.cordova/com.tenforwardconsulting.cordova.bgloc.DistanceFilterLocationService in 82050ms
  W/ActivityManager(  562): Scheduling restart of crashed service com.xpressgo.courier.cordova/com.tenforwardconsulting.cordova.bgloc.FusedLocationService in 97188832ms
  </code></pre>
  
  <p>Then after some time (97188832ms) service restarted and operates normally. But why it crashed at first place? Why there is failure sending broadcast, when services lives in their own thread? And why it won't crash again after auto restart?</p>