title: Android KitKat 4.4 kills my Service stared by Alarm Manager
body: <p>I have a big problem with Android KitKat and Alarm Manager.</p>
  
  <p>All my apps work with a service that always run in background without Android kill it.</p>
  
  <p>Before Android 4.4 KitKat the solution I found was to start the service through a BroadcastReceiver triggered by an AlarmManager.</p>
  
  <pre><code>...
  
  Intent intent = new Intent(c, MyReceiver.class);
  PendingIntent pendingIntent = PendingIntent.getBroadcast(c, 0, intent, PendingIntent.FLAG_ONE_SHOT);
          AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE);
  
          if (Build.VERSION.SDK_INT&lt;Build.VERSION_CODES.KITKAT) {
              am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), pendingIntent);
          } else {
              setAlarmFromKitkat(am, System.currentTimeMillis(), pendingIntent);
          }
  ...
  
  
  
  
  @TargetApi(19)
      private static void setAlarmFromKitkat(AlarmManager am, long ms, PendingIntent pi){
          am.setExact(AlarmManager.RTC_WAKEUP, ms, pi);
      }
  
  ...
  
  
  public class MyReceiver extends BroadcastReceiver {
  
       @Override
       public void onReceive(Context context, Intent intent) {
  
              Intent service = new Intent(context, MyService.class);
              context.startService(service);
       }
  
  }
  </code></pre>
  
  <p>On Android 4.4 KitKat by this solution I can start service but after some time Android kill it!</p>
  
  <p>Is there a way to have a Service that works in background without Android 4.4 KitKat kill it?</p>
  
  <p>Many Thanks</p>