// Mark all fired alarms as dismissed
Uri uri = CalendarAlerts.CONTENT_URI_BY_INSTANCE;
String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.FIRED;
ContentResolver resolver = getContentResolver();
Cursor cursor = resolver.query(uri, PROJECTION, selection, null, null);
if (cursor != null) {
cursor.moveToPosition(-1);
while (cursor.moveToNext()) {
cursor.updateInt(COLUMN_INDEX_STATE, CalendarAlerts.DISMISSED);
}
cursor.commitUpdates();
cursor.close();
}
// Stop this service
stopSelf();