Skip to content

Commit

Permalink
schroedingers changes. May help/may fail
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Jan 6, 2016
1 parent 68a9915 commit 2ea5914
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/src/main/java/org/schabi/terminightor/AlarmSetupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static void setupDebugAlarm(Context context) {
alarmIntent.putExtra(ALARM_TONE, "content://media/internal/audio/media/10");
alarmIntent.putExtra(ALARM_VIBRATE, true);
PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(
context, 42, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
context, 42, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);

if(Build.VERSION.SDK_INT >= 19) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmDate, alarmPendingIntent);
Expand Down Expand Up @@ -196,14 +196,16 @@ public static boolean alarmIsUp(Context context, long id) {
}

public static void cancelAlarm(Context context, long id) {
// Does only cancel the pending intent, it does not write to the database.
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent alarmIntent = new Intent(NightKillerReceiver.ACTION_FIRE_ALARM);
PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(context,
(int)id, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
(int)id, alarmIntent, 0);
alarmManager.cancel(alarmPendingIntent);
}

public static void cancelAllAlarms(Context context) {
// Does only cancel the pending intent, it does not write to the database.
Cursor cursor = AlarmDBOpenHelper.getAlarmDBOpenHelper(context).query();
cursor.moveToFirst();
AlarmDBOpenHelper.Index index = AlarmDBOpenHelper.getIndex(cursor);
Expand All @@ -218,7 +220,7 @@ public static void cancelRenewAlarm(Context context) {
Intent alarmIntent = new Intent(ACTION_RENEW_ALARMS);
PendingIntent alarmPendingIntent =
PendingIntent.getBroadcast(context, SpecialPendingIds.RENEW_ALARM,
alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT);
alarmManager.cancel(alarmPendingIntent);
}

Expand All @@ -229,7 +231,7 @@ public static void setupRenewTimer(Context context) {
Intent renewIntent = new Intent(ACTION_RENEW_ALARMS);
PendingIntent pendingSetupIntent =
PendingIntent.getBroadcast(context, SpecialPendingIds.RENEW_ALARM,
renewIntent, PendingIntent.FLAG_UPDATE_CURRENT);
renewIntent, PendingIntent.FLAG_CANCEL_CURRENT);
if(Build.VERSION.SDK_INT >= 19) {
alarmManager.setExact(
AlarmManager.RTC_WAKEUP, setupDate.getTimeInMillis(), pendingSetupIntent);
Expand Down

0 comments on commit 2ea5914

Please sign in to comment.