|
|
|
|
@ -23,6 +23,7 @@ import android.content.ContentUris;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.os.Build;
|
|
|
|
|
|
|
|
|
|
import net.micode.notes.data.Notes;
|
|
|
|
|
import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
|
@ -31,8 +32,8 @@ import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
|
public class AlarmInitReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
private static final String [] PROJECTION = new String [] {
|
|
|
|
|
NoteColumns.ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE
|
|
|
|
|
NoteColumns.ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static final int COLUMN_ID = 0;
|
|
|
|
|
@ -53,13 +54,33 @@ public class AlarmInitReceiver extends BroadcastReceiver {
|
|
|
|
|
long alertDate = c.getLong(COLUMN_ALERTED_DATE);
|
|
|
|
|
Intent sender = new Intent(context, AlarmReceiver.class);
|
|
|
|
|
sender.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, c.getLong(COLUMN_ID)));
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, sender, 0);
|
|
|
|
|
AlarmManager alermManager = (AlarmManager) context
|
|
|
|
|
|
|
|
|
|
// 修复:添加 FLAG_IMMUTABLE 标志
|
|
|
|
|
PendingIntent pendingIntent;
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
|
|
pendingIntent = PendingIntent.getBroadcast(
|
|
|
|
|
context,
|
|
|
|
|
0,
|
|
|
|
|
sender,
|
|
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
pendingIntent = PendingIntent.getBroadcast(
|
|
|
|
|
context,
|
|
|
|
|
0,
|
|
|
|
|
sender,
|
|
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AlarmManager alarmManager = (AlarmManager) context
|
|
|
|
|
.getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
alermManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent);
|
|
|
|
|
|
|
|
|
|
// 额外修复:修正变量名拼写错误
|
|
|
|
|
alarmManager.set(AlarmManager.RTC_WAKEUP, alertDate, pendingIntent);
|
|
|
|
|
} while (c.moveToNext());
|
|
|
|
|
}
|
|
|
|
|
c.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|