android : remove all alarm when on onDeleted() for AppWidgetProvider
<p>I'm working on a widget that set repeating alarms to refresh.</p>

<p>To set these repeating alarms, in the configuration Activity, in an OnClickListener(), I do :</p>

<pre><code>        Intent widgetUpdate = new Intent();
        widgetUpdate.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
        widgetUpdate.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,mAppWidgetId);
        widgetUpdate.setData(Uri.withAppendedPath(Uri.parse("wd_widget://widget/id/"), String.valueOf(mAppWidgetId)));

        PendingIntent newPending = PendingIntent.getBroadcast(context, 0, widgetUpdate, PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

        int mins = 60;
        alarms.cancel(newPending);
        alarms.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),  mins*1000*60,newPending);
</code></pre>

<p>And my AppwidgetProvider receive this intent in onReceive(), and refresh the view : </p>

<pre><code>if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(intent.getAction())) {
            Bundle extras = intent.getExtras();
            if(extras!=null) {
                int widgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
                updateAppWidget(context, AppWidgetManager.getInstance(context), widgetId);
            }
</code></pre>

<p>My problem : 
When I kill the Widget, Alarm stay active althought I do in onDeleted() of AppwidgetProvider: </p>

<pre><code>Intent widgetUpdate = new Intent();
    widgetUpdate.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    PendingIntent newPending = PendingIntent.getBroadcast(context, 0, widgetUpdate, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    for (int appWidgetId : appWidgetIds) {      
        Log.i("DEBUG","Removing Alarms");
        alarms.cancel(newPending);
    }
</code></pre>

<p>So how to kill all the alarm when leaving the widget ? 
Best, 
Christophe.</p>
