title: Android-Service killed with "no longer want" - how to restart it?
body: <p>We have a Service that continuously collects sensor data on the phone. This service should run "forever", e.g. as long as the user wants, and not be killed by the system.</p>
  
  <p>For clarification, this service is <strong>not</strong> intended for an app to be released in the market to the general public, it is written for a scientific study. So the people running the app are fully aware that their battery will sucked empty faster than usual, this is no problem.</p>
  
  <p>Anyways, my problem is that the service gets killed after a while of running. Sometimes after an hour, sometimes only after like 7 oder 10 hours.</p>
  
  <p>The Log-Entries when the service gets killed look like this. It just says "<em>no longer want</em>", sometimes without even calling onDestroy(), as far as I can tell.</p>
  
  <pre><code>07-20 17:07:11.593 I/ActivityManager(   85): No longer want my.project.datalogging (pid 23918): hidden #16
  07-20 17:07:11.593 I/WindowManager(   85): WIN DEATH: Window{44c61570 my.project.datalogging/my.project.datalogging.DataLoggingApp paused=false}
  07-20 17:07:11.603 I/BackgroundService(23925): onDestroy()
  </code></pre>
  
  <p>Or later (after I manually restarted it): </p>
  
  <pre><code>07-20 19:00:49.677 I/ActivityManager(   85): No longer want my.project.datalogging:BackgroundService (pid 24421): hidden #17
  07-20 19:00:49.677 I/ActivityManager(   85): No longer want my.project.datalogging (pid 24415): hidden #18
  07-20 19:00:49.807    85 10707 I WindowManager: WIN DEATH: Window{44f1ea58 my.project.datalogging/my.project.datalogging.DataLoggingApp paused=false}
  </code></pre>
  
  <p>I often see other services being killed with "<em>no longer want</em>" and then immediately restarted with "<em>Scheduling restart of crashed service</em>". For example here with runkeeper: </p>
  
  <pre><code>07-20 17:30:45.503 I/ActivityManager(   85): No longer want com.fitnesskeeper.runkeeper (pid 24090): hidden #16
  07-20 17:30:45.603 W/ActivityManager(   85): Scheduling restart of crashed service com.fitnesskeeper.runkeeper/.services.RunKeeperService in 5000ms
  07-20 17:33:52.989 I/ActivityManager(   85): Start proc com.fitnesskeeper.runkeeper for service com.fitnesskeeper.runkeeper/.services.RunKeeperService: pid=24292 uid=10099 gids={3003, 1015}
  </code></pre>
  
  <p>The logs show no record of low memory. Testing is done on (several) Nexus One with 2.2 (Froyo FRF91).</p>
  
  <p>Is there any way I can achieve this behaviour with my app? Automatic restarting after being killed?</p>
  
  <p>Or this this something totally different that just looks similar in logcat?</p>
  
  <p>If you need any more information, just ask and I'll try to provide it :-)</p>