title: Time taken for Android Service to restart after being forcibly killed
body: <p>When I use an app such as "Go Power Master" to forcibly kill Services running on my Android phone, not all Services restart with the same delay. Why is this and how do I reduce the time taken for my Service to restart?</p>
  
  <p>The Facebook Service is a perfect example. Below is its LogCat output while it was killed 3 times in succession. Notice the restart times in bold: 14992ms, 5000ms, 14963ms.</p>
  
  <p>My Service is not treated so well. Below is its LogCat output while it was killed 3 times in succession. Notice the much larger restart times in bold: 23358ms, 93432ms, 373728ms.</p>
  
  <p>The complete source code for this project is on GitHub.
  <a href="https://github.com/ccoffey/NUIMWiFi" rel="nofollow">https://github.com/ccoffey/NUIMWiFi</a></p>
  
  <p><em><strong>Facebook LogCat</em></strong></p>
  
  <p>05-10 14:09:33.381: I/ActivityManager(192): Killing proc 7280:com.facebook.katana/10077: kill background
  05-10 14:09:33.381: W/ActivityManager(192): Scheduling restart of crashed service com.facebook.katana/.service.MediaUploadService in <strong>14992ms</strong>
  05-10 14:09:48.412: I/ActivityManager(192): Start proc com.facebook.katana for service com.facebook.katana/.service.MediaUploadService: pid=7847 uid=10077 gids={3003, 1006, 1015}
  05-10 14:09:48.568: I/ActivityThread(7847): Pub com.facebook.katana.provider.LoggingProvider: com.facebook.katana.provider.LoggingProvider
  05-10 14:09:48.592: I/ActivityThread(7847): Pub com.facebook.katana.provider.KeyValueProvider: com.facebook.katana.provider.KeyValueProvider
  05-10 14:09:48.592: I/ActivityThread(7847): Pub com.facebook.katana.provider.CacheProvider: com.facebook.katana.provider.CacheProvider
  05-10 14:09:48.592: I/ActivityThread(7847): Pub com.facebook.katana.provider.MailboxProvider: com.facebook.katana.provider.MailboxProvider
  05-10 14:09:48.599: I/ActivityThread(7847): Pub com.facebook.katana.provider.UserStatusesProvider: com.facebook.katana.provider.UserStatusesProvider
  05-10 14:09:48.599: I/ActivityThread(7847): Pub com.facebook.katana.provider.EventsProvider: com.facebook.katana.provider.EventsProvider
  05-10 14:09:48.607: I/ActivityThread(7847): Pub com.facebook.katana.provider.NotificationsProvider: com.facebook.katana.provider.NotificationsProvider
  05-10 14:09:48.607: I/ActivityThread(7847): Pub com.facebook.katana.provider.UserValuesProvider: com.facebook.katana.provider.UserValuesProvider
  05-10 14:09:48.607: I/ActivityThread(7847): Pub com.facebook.katana.provider.PagesProvider: com.facebook.katana.provider.PagesProvider
  05-10 14:09:48.607: I/ActivityThread(7847): Pub com.facebook.katana.provider.MobileEventLogProvider: com.facebook.katana.provider.MobileEventLogProvider
  05-10 14:09:48.607: I/ActivityThread(7847): Pub com.facebook.katana.provider.PushNotificationsProvider: com.facebook.katana.provider.PushNotificationsProvider
  05-10 14:09:48.615: I/ActivityThread(7847): Pub com.facebook.katana.provider.PhotosProvider: com.facebook.katana.provider.PhotosProvider
  05-10 14:09:48.615: I/ActivityThread(7847): Pub com.facebook.katana.provider.ConnectionsProvider: com.facebook.katana.provider.ConnectionsProvider
  05-10 14:09:48.623: I/ActivityThread(7847): Pub com.facebook.orca.notify.FbandroidMessagesForegroundProvider: com.facebook.orca.notify.FbandroidMessagesForegroundProvider
  05-10 14:09:48.639: D/ACRA(7847): ACRA is enabled for com.facebook.katana, intializing...
  05-10 14:09:48.654: D/ACRA(7847): Looking for error files in /data/data/com.facebook.katana/app_acra-reports
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.inject.binder.AnnotatedBindingBuilderImpl.a(AnnotatedBindingBuilderImpl.java:22)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.app.FbBaseModule.a(FbBaseModule.java:73)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.inject.AbstractModule.a(AbstractModule.java:19)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.inject.FbInjectorImpl.a(FbInjectorImpl.java:61)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.inject.FbInjectorImpl.(FbInjectorImpl.java:41)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.orca.inject.FbInjector.a(FbInjector.java:40)
  05-10 14:09:48.701: W/nalizableReferenceQueue(7847):    at com.facebook.katana.FacebookApplication.onCreate(FacebookApplication.java:75)
  05-10 14:09:48.928: I/SqliteDatabaseCpp(7847): sqlite returned: error code = 21, msg = misuse at line 105099 of [8609a15dfa], db=/data/data/com.facebook.katana/databases/prefs_db
  05-10 14:09:53.810: I/ActivityManager(192): Killing proc 7847:com.facebook.katana/10077: kill background
  05-10 14:09:53.810: W/ActivityManager(192): Scheduling restart of crashed service com.facebook.katana/.service.MediaUploadService in <strong>5000ms</strong>
  05-10 14:09:58.842: I/ActivityManager(192): Start proc com.facebook.katana for service com.facebook.katana/.service.MediaUploadService: pid=7890 uid=10077 gids={3003, 1006, 1015}
  05-10 14:09:59.053: I/ActivityThread(7890): Pub com.facebook.katana.provider.LoggingProvider: com.facebook.katana.provider.LoggingProvider
  05-10 14:09:59.060: I/ActivityThread(7890): Pub com.facebook.katana.provider.KeyValueProvider: com.facebook.katana.provider.KeyValueProvider
  05-10 14:09:59.060: I/ActivityThread(7890): Pub com.facebook.katana.provider.CacheProvider: com.facebook.katana.provider.CacheProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.MailboxProvider: com.facebook.katana.provider.MailboxProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.UserStatusesProvider: com.facebook.katana.provider.UserStatusesProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.EventsProvider: com.facebook.katana.provider.EventsProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.NotificationsProvider: com.facebook.katana.provider.NotificationsProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.UserValuesProvider: com.facebook.katana.provider.UserValuesProvider
  05-10 14:09:59.076: I/ActivityThread(7890): Pub com.facebook.katana.provider.PagesProvider: com.facebook.katana.provider.PagesProvider
  05-10 14:09:59.084: I/ActivityThread(7890): Pub com.facebook.katana.provider.MobileEventLogProvider: com.facebook.katana.provider.MobileEventLogProvider
  05-10 14:09:59.084: I/ActivityThread(7890): Pub com.facebook.katana.provider.PushNotificationsProvider: com.facebook.katana.provider.PushNotificationsProvider
  05-10 14:09:59.084: I/ActivityThread(7890): Pub com.facebook.katana.provider.PhotosProvider: com.facebook.katana.provider.PhotosProvider
  05-10 14:09:59.084: I/ActivityThread(7890): Pub com.facebook.katana.provider.ConnectionsProvider: com.facebook.katana.provider.ConnectionsProvider
  05-10 14:09:59.092: I/ActivityThread(7890): Pub com.facebook.orca.notify.FbandroidMessagesForegroundProvider: com.facebook.orca.notify.FbandroidMessagesForegroundProvider
  05-10 14:09:59.154: D/ACRA(7890): ACRA is enabled for com.facebook.katana, intializing...
  05-10 14:09:59.185: D/ACRA(7890): Looking for error files in /data/data/com.facebook.katana/app_acra-reports
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.inject.binder.AnnotatedBindingBuilderImpl.a(AnnotatedBindingBuilderImpl.java:22)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.app.FbBaseModule.a(FbBaseModule.java:73)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.inject.AbstractModule.a(AbstractModule.java:19)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.inject.FbInjectorImpl.a(FbInjectorImpl.java:61)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.inject.FbInjectorImpl.(FbInjectorImpl.java:41)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.orca.inject.FbInjector.a(FbInjector.java:40)
  05-10 14:09:59.232: W/nalizableReferenceQueue(7890):    at com.facebook.katana.FacebookApplication.onCreate(FacebookApplication.java:75)
  05-10 14:10:44.826: I/ActivityManager(192): Killing proc 7890:com.facebook.katana/10077: kill background
  05-10 14:10:44.826: W/ActivityManager(192): Scheduling restart of crashed service com.facebook.katana/.service.MediaUploadService in <strong>14963ms</strong></p>
  
  <p><em><strong>MyService LogCat</em></strong></p>
  
  <p>I/ActivityManager(  192): Killing proc 8556:ie.cathalcoffey.android/10033: kill background
  I/ActivityManager(  192): Killing proc 8606:ie.cathalcoffey.android:remote/10033: kill background
  W/ActivityManager(  192): Scheduling restart of crashed service ie.cathalcoffey.android/.MyService in <strong>23358ms</strong>
  I/ActivityManager(  192): Start proc ie.cathalcoffey.android:remote for service ie.cathalcoffey.android/.MyService: pid=8726 uid=10033 gids={3003}
  I/ActivityManager(  192): Killing proc 8726:ie.cathalcoffey.android:remote/10033: kill background
  W/ActivityManager(  192): Scheduling restart of crashed service ie.cathalcoffey.android/.MyService in <strong>93432ms</strong>
  I/ActivityManager(  192): Start proc ie.cathalcoffey.android:remote for service ie.cathalcoffey.android/.MyService: pid=9063 uid=10033 gids={3003}
  I/ActivityManager(  192): Killing proc 9063:ie.cathalcoffey.android:remote/10033: kill background
  W/ActivityManager(  192): Scheduling restart of crashed service ie.cathalcoffey.android/.MyService in <strong>373728ms</strong></p>