How to create a persistent AlarmManager
<p>Edit: Clarified the question based on CommonsWare's answer</p>

<p>We're scheduling an an alarm via AlarmManager to trigger every 60 seconds. When our application is killed our alarms seem to no longer execute. Is there a way to make these alarms persist even when the application is killed manually or by the system? </p>

<p>This is a problem for us because we have a widget application that displays the time. This means we need to update the time every minute. To get around the 30 minute update limit on the onUpdate method of AppWidgetProvider we use AlarmManager. It usually works pretty well, but some users have reported the time going out of sync. After talking to several of them, my suspicion is that our application is being killed manually via a task killer app or Android is itself is killing our app.</p>

<p>Any other alternate solutions to the root problem (keeping the time in sync in a widget) welcome as well.</p>

<p>Here is the code we execute to schedule our alarm:</p>

<pre><code>Intent intent = new Intent(UPDATE_TIME);
PendingIntent pIntent = PendingIntent.getBroadcast(ctx,
  0 /* no requestCode */, intent, PendingIntent.FLAG_UPDATE_CURRENT );

// get alarm params
Date d = new Date();
long timeTilMinuteChange = 60*1000-d.getSeconds()*1000;
long startTime = System.currentTimeMillis() + + timeTilMinuteChange;

AlarmManager am = (AlarmManager) ctx.getSystemService(Context.
am.cancel(pIntent);
am.set(AlarmManager.RTC, System.currentTimeMillis(), pIntent);
        am.setRepeating(AlarmManager.RTC, startTime, 60000, pIntent);
</code></pre>
